I have this feature to add custom meta fields to product details in all WooCommerce emails. But I only need it to show up after the order has been paid for (this can also be just a "completed" email).
1 2 3 4 5 6 7 8 9 10 11 |
|
I wish I could nest it inside a if ( $email->id == 'customer_completed_order' ) {}
so the final code would look like this:
1 2 3 4 5 6 7 8 9 10 11 12 13 |
|
But after changing it it stopped working. Any suggestions?
P粉0142937382024-01-09 18:05:49
As you can see in the code try, $email
is not part of the woocommerce_order_item_meta_start
hook. So, to target certain WooCommerce email notifications, you need a workaround.
Step 1) Create and add a global variable via another hook that only works for WooCommerce email notifications.
1 2 3 4 5 |
|
Step 2) In the hook woocommerce_order_item_meta_start
, use a global variable so that we can target certain WooCommerce email notifications
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
|