WordPress Development Asked by user3344734 on February 20, 2021
I have multilingual ACF option fields with a language code suffix appended to the field name, so in the woocommerce customer-invoice.php
file I am outputting fields based on customers billing and shipping address.
Im trying to make these field translations work in my customised woocommerce footer email templates. In my customer-invoice.php
file I have set so that an order with order status enquiry loads my custom footer template:
elseif ($order->has_status('enquiry')) {
wc_get_template( 'emails/email-header-quote.php', array( 'email_heading' => $email_heading_quote ) ) ;
This works, but it doesn’t pass the $order
object, so I cant get the language suffix in order to get the correct ACF option field.
The only thing that I have managed to have any luck with it is if I add
add_action('woocommerce_email_footer', function ($email) {
if (!isset($GLOBALS['wc_email'])) {
$GLOBALS['wc_email'] = $email;
}
}, 1, 1);
do_action( 'woocommerce_email_footer', $email );
To my customer-invoice.php file (doesn’t work if I put it in my function file)
and if I reference it in my customer footer template:
$order = null;
if (isset($GLOBALS['wc_email']) && $GLOBALS['wc_email']->object && $GLOBALS['wc_email']->object instanceof WC_Order) {
$order = $GLOBALS['wc_email']->object;
}
This brings me the correct translation. The problem is that this will load the default footer template on top of my custom footer template.
What is the best way to pass the $order
object to my custom woocommerce email footer template?
Get help from others!
Recent Questions
Recent Answers
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP