Quantcast
Channel: WordPress.org Forums » [WooCommerce] Support
Viewing all articles
Browse latest Browse all 104029

Edit email-order-items.php for Efficiency

$
0
0

Replies: 1

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 all articles
Browse latest Browse all 104029

Trending Articles