• Resolved mindykatzen

    (@mindykatzen)


    Active: HPOS
    Active: “Enable modern email design and live preview for transactional emails”.
    Copied email-order-items.php, @version 9.7.0, to the child theme directory as required.

    I need an order meta to use, $my_meta = $order->get_meta(‘my_meta’);
    $my_meta is an array from serialized data.

    (1) If that command is entered above this line near the top
    foreach ($items as $item_id => $item) {

    And the data are used just above
    do_action(‘woocommerce_order_item_meta_end’, $item_id, $item, $order, $plain_text);

    The variable, $my_meta no longer exists and cannot be used.

    (2) If $my_meta = $order->get_meta(‘my_meta’); is moved above the cited do_action, then $my_meta data are there and can be used.

    The reason to set the $my_meta before the loop is because it has data for each order item within the loop. I prefer to set that variable outside the loop to get the data only once when that page is executed, not once for every item. That is, if there are 10 items in the order, then that command, $order->get_meta would be run 10 times, not once.

    QUESTION: Is there a way to call the $order->get_meta only once for this?


Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter mindykatzen

    (@mindykatzen)

    Ignore this. There was an error in the code. It’s working as expected if I assign the meta before the loop.

    Hi @mindykatzen,

    I’m glad you were able to resolve the issue on your end. Just to clarify, this forum is meant for addressing WooCommerce core issues and concerns. Since your request involves custom code and customization, it falls outside our support scope. If you need further guidance on your custom approach, I recommend consulting an expert.

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘Edit email-order-items.php for Efficiency’ is closed to new replies.