Published in WordPress
avatar
2 minutes read

How to get order items ids to get some product meta data?

I'm attempting to separate thing meta esteem from Woocommerce's requests by utilizing:

$data = wc_get_order_item_meta( $item, '_tmcartepo_data', true );

Nonetheless, I can't figure out how to get order_item_id as the principal boundary (utilizing get_items)

global $woocommerce, $post, $wpdb;
$order = new WC_Order($post->ID);
$items = $order->get_items(); 

foreach ( $items as $item ) {
    $item_id = $item['order_item_id']; //???
    $data = wc_get_order_item_meta( $item_id, '_tmcartepo_data', true );
    $a = $data[0]['value'];
    $b = $data[1]['value'];
    echo $a;
    echo $b;
}

Also, I mean this request item_id (1 and 2)

Order_item_id in data set - Picture

How might I wear that?

Much obliged.

Comments