Hey I’m attempting to construct a shortcode for my order particulars on the order obtained web page.
The code under will generate the final outcome after which on prime of it, it’s going to show the phrase Array.
I really feel like i’m doing one thing unsuitable with the shortcode_atts however I actually don’t know what it’s.
Any assist can be appreciated.
UPDATE:
I made some modifications however it’s nonetheless returning the phrase array after which the final merchandise. I really feel like it’s my foreach loop, however i dont know what to do subsequent.
operate getOrderItemList(){
//arrange array and Rely
$item_data="";
//get order ID
world $wp;
$order_id = absint( $wp->query_vars['order-received'] );
$order = wc_get_order( $order_id );
$order_line_items = $order->get_items();
//loop by way of every merchandise within the order
foreach ($order_line_items as $merchandise) {
$product = $item->get_product();
$product_id = $item->get_product_id();
$item_data = $item->get_data();
$product_name = $item->get_name();
$item_quantity = $item->get_quantity();
$item_total = $order->get_formatted_line_subtotal( $merchandise );
$product_image = $product->get_image('order-received-item-image', $merchandise);
$item_data .= '<tr class="order-item-row"><td class="order-item-image">' . $product_image . '</td><td class="order-item-name"><p>' . $product_name . ' x ' . $item_quantity . '</p></td><td class="order-item-total"><p>' . $item_total . '</p></td></tr>';
}
$item_list = $item_data;
$desk .= <<<EOD
<desk class="check">
$item_list
</desk>
EOD;
return $desk;
}
add_shortcode('order-line-item', 'getOrderItemList');