Problem getting data with WooCommerce/WordPress

I think the problem is you are trying to access the wc_get_order_item_meta from the WC_Order class. But there is no function in that class with that name. I googled the function name, and found that this function should be called not from the WC_Order class, but directly.

Try this;

$order = new WC_Order($order_id);
$order_items = $order->get_items();
$text = "";
$text .= $order_id;
foreach ($order_items as $item_id => $item_data) {
    $item_date = wc_get_order_item_meta($item_id, 'luxvila_order', true);
    $text .= "\ndate:".$item_date."\n";
}
file_put_contents("b.txt", $text);
 

Leave a Comment