wordpress - Woocommerce switch language on order completed mail -


i'm using woocommerce + wpml , set programmatically email order completed. i'm trying using $sitepress->switch_lang() seems not work.

add_action( 'woocommerce_order_status_completed', 'mysite_woocommerce_order_status_completed' );  function mysite_woocommerce_order_status_completed($order_id) {     global $sitepress;     $sitepress->switch_lang('en', true);     if($sitepress->get_current_language() == 'en')     {        $mailer = wc()->mailer();        $recipient = 'customer@mail.com';        $subject = 'your order has been completed';        $content = get_processing_notification_content_completed( $order, $subject, $mailer );        $headers = "content-type: text/html\r\n";         $mailer->send( $recipient, $subject, $content, $headers );     } }  function get_processing_notification_content_completed( $order, $heading = false, $mailer ) {     $template = 'emails/customer-completed-order.php';      return wc_get_template_html( $template, array(       'order'         => $order,       'email_heading' => $heading,       'sent_to_admin' => true,       'plain_text'    => false,       'email'         => $mailer     ) ); } 

although use "switch_lang()", mails continues show in italian language.


Comments

Popular posts from this blog

php - Permission denied. Laravel linux server -

google bigquery - Delta between query execution time and Java query call to finish -

python - Pandas two dataframes multiplication? -