Use store language in customer emails

This commit is contained in:
claudiulodro 2017-05-15 14:34:37 -07:00
parent 05132f724c
commit 838b175f67
9 changed files with 40 additions and 3 deletions

View File

@ -26,6 +26,8 @@ class WC_Email_Customer_Completed_Order extends WC_Email {
$this->id = 'customer_completed_order';
$this->customer_email = true;
$this->setup_locale();
$this->title = __( 'Completed order', 'woocommerce' );
$this->description = __( 'Order complete emails are sent to customers when their orders are marked completed and usually indicate that their orders have been shipped.', 'woocommerce' );
@ -44,6 +46,7 @@ class WC_Email_Customer_Completed_Order extends WC_Email {
// Call parent constuctor
parent::__construct();
$this->restore_locale();
}
/**

View File

@ -39,6 +39,9 @@ class WC_Email_Customer_Invoice extends WC_Email {
public function __construct() {
$this->id = 'customer_invoice';
$this->customer_email = true;
$this->setup_locale();
$this->title = __( 'Customer invoice', 'woocommerce' );
$this->description = __( 'Customer invoice emails can be sent to customers containing their order information and payment links.', 'woocommerce' );
@ -54,10 +57,10 @@ class WC_Email_Customer_Invoice extends WC_Email {
// Call parent constructor
parent::__construct();
$this->customer_email = true;
$this->manual = true;
$this->heading_paid = $this->get_option( 'heading_paid', $this->heading_paid );
$this->subject_paid = $this->get_option( 'subject_paid', $this->subject_paid );
$this->restore_locale();
}
/**

View File

@ -54,6 +54,8 @@ class WC_Email_Customer_New_Account extends WC_Email {
$this->id = 'customer_new_account';
$this->customer_email = true;
$this->setup_locale();
$this->title = __( 'New account', 'woocommerce' );
$this->description = __( 'Customer "new account" emails are sent to the customer when a customer signs up via checkout or account pages.', 'woocommerce' );
@ -65,6 +67,7 @@ class WC_Email_Customer_New_Account extends WC_Email {
// Call parent constructor
parent::__construct();
$this->restore_locale();
}
/**

View File

@ -33,6 +33,8 @@ class WC_Email_Customer_Note extends WC_Email {
$this->id = 'customer_note';
$this->customer_email = true;
$this->setup_locale();
$this->title = __( 'Customer note', 'woocommerce' );
$this->description = __( 'Customer note emails are sent when you add a note to an order.', 'woocommerce' );
@ -47,6 +49,7 @@ class WC_Email_Customer_Note extends WC_Email {
// Call parent constructor
parent::__construct();
$this->restore_locale();
}
/**

View File

@ -25,6 +25,8 @@ class WC_Email_Customer_On_Hold_Order extends WC_Email {
public function __construct() {
$this->id = 'customer_on_hold_order';
$this->customer_email = true;
$this->setup_locale();
$this->title = __( 'Order on-hold', 'woocommerce' );
$this->description = __( 'This is an order notification sent to customers containing order details after an order is placed on-hold.', 'woocommerce' );
$this->heading = __( 'Thank you for your order', 'woocommerce' );
@ -38,6 +40,7 @@ class WC_Email_Customer_On_Hold_Order extends WC_Email {
// Call parent constructor
parent::__construct();
$this->restore_locale();
}
/**

View File

@ -25,6 +25,8 @@ class WC_Email_Customer_Processing_Order extends WC_Email {
public function __construct() {
$this->id = 'customer_processing_order';
$this->customer_email = true;
$this->setup_locale();
$this->title = __( 'Processing order', 'woocommerce' );
$this->description = __( 'This is an order notification sent to customers containing order details after payment.', 'woocommerce' );
$this->heading = __( 'Thank you for your order', 'woocommerce' );
@ -38,6 +40,7 @@ class WC_Email_Customer_Processing_Order extends WC_Email {
// Call parent constructor
parent::__construct();
$this->restore_locale();
}
/**

View File

@ -37,8 +37,9 @@ class WC_Email_Customer_Refunded_Order extends WC_Email {
* Constructor.
*/
public function __construct() {
$this->set_email_strings();
$this->customer_email = true;
$this->setup_locale();
$this->set_email_strings();
// Triggers for this email
add_action( 'woocommerce_order_fully_refunded_notification', array( $this, 'trigger_full' ), 10, 2 );
@ -46,6 +47,7 @@ class WC_Email_Customer_Refunded_Order extends WC_Email {
// Call parent constuctor
parent::__construct();
$this->restore_locale();
}
/**

View File

@ -46,9 +46,11 @@ class WC_Email_Customer_Reset_Password extends WC_Email {
public function __construct() {
$this->id = 'customer_reset_password';
$this->customer_email = true;
$this->setup_locale();
$this->title = __( 'Reset password', 'woocommerce' );
$this->description = __( 'Customer "reset password" emails are sent when customers reset their passwords.', 'woocommerce' );
$this->customer_email = true;
$this->template_html = 'emails/customer-reset-password.php';
$this->template_plain = 'emails/plain/customer-reset-password.php';
@ -61,6 +63,7 @@ class WC_Email_Customer_Reset_Password extends WC_Email {
// Call parent constructor
parent::__construct();
$this->restore_locale();
}
/**

View File

@ -243,6 +243,18 @@ class WC_Email extends WC_Settings_API {
return str_replace( apply_filters( 'woocommerce_email_format_string_find', $this->find, $this ), apply_filters( 'woocommerce_email_format_string_replace', $this->replace, $this ), $string );
}
public function setup_locale() {
if ( function_exists( 'switch_to_locale' ) && $this->is_customer_email() ) {
switch_to_locale( get_locale() );
}
}
public function restore_locale( $email ) {
if ( function_exists( 'restore_previous_locale' ) && $this->is_customer_email() ) {
restore_previous_locale();
}
}
/**
* Get email subject.
*
@ -388,6 +400,7 @@ class WC_Email extends WC_Settings_API {
* @return string
*/
public function get_content() {
$this->setup_locale();
$this->sending = true;
if ( 'plain' === $this->get_email_type() ) {
@ -395,6 +408,7 @@ class WC_Email extends WC_Settings_API {
} else {
$email_content = $this->get_content_html();
}
$this->restore_locale();
return wordwrap( $email_content, 70 );
}