I am trying to put the ordered items in a array to pass the values further in woocommerce thank you page. I am currently getting all line item names, sku etc without comma or anything.
foreach ($order->get_items() as $item_id => $item_data) {
// Get an instance of corresponding the WC_Product object
$product = $item_data->get_product();
$product_name = $product->get_name(); // Get the product name
$item_quantity = $item_data->get_quantity(); // Get the item quantity
$sku = $product->get_sku();
$item_total = $item_data->get_total(); // Get the item line total
// Displaying this data (to check)
echo 'NAME: '.$product_name.' | Quantity: '.$item_quantity.' | Item total: '. number_format( $item_total, 2 );
}
Current Results