-
-
Save stinGeorge/d0eecb98c0c5caf1d074af8ce9aae61b to your computer and use it in GitHub Desktop.
Loop through WooCommerce order products
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$count = 1; | |
foreach( $order->get_items() as $item_id => $line_item ){ | |
$item_data = $line_item->get_data(); | |
$product = $line_item->get_product(); | |
$product_name = $product->get_name(); | |
$item_quantity = $line_item->get_quantity(); | |
$item_total = $line_item->get_total(); | |
$metadata['Line Item '.$count] = 'Product name: '.$product_name.' | Quantity: '.$item_quantity.' | Item total: '. number_format( $item_total, 2 ); | |
$count += 1; | |
} | |
return $metadata; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment