@rollin
To loop through order item quantities in WooCommerce, you can use the following code snippet:
1 2 3 4 5 6 7 8 9 |
$order = new WC_Order( $order_id ); //replace $order_id with the ID of the order you want to loop through foreach( $order->get_items() as $item_id => $item ){ $product = $item->get_product(); $quantity = $item->get_quantity(); // Output the quantity echo 'Quantity: ' . $quantity; } |
This code snippet retrieves the order by its ID, then loops through each order item and gets the quantity of each item. You can then use this quantity for further processing as needed.