Merge pull request #17352 from woocommerce/fix/17324
Setup locale before generating placeholders
This commit is contained in:
commit
f8552ebbad
|
@ -72,6 +72,8 @@ class WC_Email_Cancelled_Order extends WC_Email {
|
|||
* @param WC_Order $order Order object.
|
||||
*/
|
||||
public function trigger( $order_id, $order = false ) {
|
||||
$this->setup_locale();
|
||||
|
||||
if ( $order_id && ! is_a( $order, 'WC_Order' ) ) {
|
||||
$order = wc_get_order( $order_id );
|
||||
}
|
||||
|
@ -82,12 +84,10 @@ class WC_Email_Cancelled_Order extends WC_Email {
|
|||
$this->placeholders['{order_number}'] = $this->object->get_order_number();
|
||||
}
|
||||
|
||||
if ( ! $this->is_enabled() || ! $this->get_recipient() ) {
|
||||
return;
|
||||
if ( $this->is_enabled() && $this->get_recipient() ) {
|
||||
$this->send( $this->get_recipient(), $this->get_subject(), $this->get_content(), $this->get_headers(), $this->get_attachments() );
|
||||
}
|
||||
|
||||
$this->setup_locale();
|
||||
$this->send( $this->get_recipient(), $this->get_subject(), $this->get_content(), $this->get_headers(), $this->get_attachments() );
|
||||
$this->restore_locale();
|
||||
}
|
||||
|
||||
|
|
|
@ -49,6 +49,8 @@ class WC_Email_Customer_Completed_Order extends WC_Email {
|
|||
* @param WC_Order $order Order object.
|
||||
*/
|
||||
public function trigger( $order_id, $order = false ) {
|
||||
$this->setup_locale();
|
||||
|
||||
if ( $order_id && ! is_a( $order, 'WC_Order' ) ) {
|
||||
$order = wc_get_order( $order_id );
|
||||
}
|
||||
|
@ -60,12 +62,10 @@ class WC_Email_Customer_Completed_Order extends WC_Email {
|
|||
$this->placeholders['{order_number}'] = $this->object->get_order_number();
|
||||
}
|
||||
|
||||
if ( ! $this->is_enabled() || ! $this->get_recipient() ) {
|
||||
return;
|
||||
if ( $this->is_enabled() && $this->get_recipient() ) {
|
||||
$this->send( $this->get_recipient(), $this->get_subject(), $this->get_content(), $this->get_headers(), $this->get_attachments() );
|
||||
}
|
||||
|
||||
$this->setup_locale();
|
||||
$this->send( $this->get_recipient(), $this->get_subject(), $this->get_content(), $this->get_headers(), $this->get_attachments() );
|
||||
$this->restore_locale();
|
||||
}
|
||||
|
||||
|
|
|
@ -110,6 +110,8 @@ class WC_Email_Customer_Invoice extends WC_Email {
|
|||
* @param WC_Order $order Order object.
|
||||
*/
|
||||
public function trigger( $order_id, $order = false ) {
|
||||
$this->setup_locale();
|
||||
|
||||
if ( $order_id && ! is_a( $order, 'WC_Order' ) ) {
|
||||
$order = wc_get_order( $order_id );
|
||||
}
|
||||
|
@ -121,12 +123,10 @@ class WC_Email_Customer_Invoice extends WC_Email {
|
|||
$this->placeholders['{order_number}'] = $this->object->get_order_number();
|
||||
}
|
||||
|
||||
if ( ! $this->get_recipient() ) {
|
||||
return;
|
||||
if ( $this->get_recipient() ) {
|
||||
$this->send( $this->get_recipient(), $this->get_subject(), $this->get_content(), $this->get_headers(), $this->get_attachments() );
|
||||
}
|
||||
|
||||
$this->setup_locale();
|
||||
$this->send( $this->get_recipient(), $this->get_subject(), $this->get_content(), $this->get_headers(), $this->get_attachments() );
|
||||
$this->restore_locale();
|
||||
}
|
||||
|
||||
|
|
|
@ -90,6 +90,7 @@ class WC_Email_Customer_New_Account extends WC_Email {
|
|||
* @param bool $password_generated
|
||||
*/
|
||||
public function trigger( $user_id, $user_pass = '', $password_generated = false ) {
|
||||
$this->setup_locale();
|
||||
|
||||
if ( $user_id ) {
|
||||
$this->object = new WP_User( $user_id );
|
||||
|
@ -101,12 +102,10 @@ class WC_Email_Customer_New_Account extends WC_Email {
|
|||
$this->password_generated = $password_generated;
|
||||
}
|
||||
|
||||
if ( ! $this->is_enabled() || ! $this->get_recipient() ) {
|
||||
return;
|
||||
if ( $this->is_enabled() && $this->get_recipient() ) {
|
||||
$this->send( $this->get_recipient(), $this->get_subject(), $this->get_content(), $this->get_headers(), $this->get_attachments() );
|
||||
}
|
||||
|
||||
$this->setup_locale();
|
||||
$this->send( $this->get_recipient(), $this->get_subject(), $this->get_content(), $this->get_headers(), $this->get_attachments() );
|
||||
$this->restore_locale();
|
||||
}
|
||||
|
||||
|
|
|
@ -75,6 +75,8 @@ class WC_Email_Customer_Note extends WC_Email {
|
|||
* @param array $args
|
||||
*/
|
||||
public function trigger( $args ) {
|
||||
$this->setup_locale();
|
||||
|
||||
if ( ! empty( $args ) ) {
|
||||
$defaults = array(
|
||||
'order_id' => '',
|
||||
|
@ -90,17 +92,13 @@ class WC_Email_Customer_Note extends WC_Email {
|
|||
$this->customer_note = $customer_note;
|
||||
$this->placeholders['{order_date}'] = wc_format_datetime( $this->object->get_date_created() );
|
||||
$this->placeholders['{order_number}'] = $this->object->get_order_number();
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! $this->is_enabled() || ! $this->get_recipient() ) {
|
||||
return;
|
||||
if ( $this->is_enabled() && $this->get_recipient() ) {
|
||||
$this->send( $this->get_recipient(), $this->get_subject(), $this->get_content(), $this->get_headers(), $this->get_attachments() );
|
||||
}
|
||||
|
||||
$this->setup_locale();
|
||||
$this->send( $this->get_recipient(), $this->get_subject(), $this->get_content(), $this->get_headers(), $this->get_attachments() );
|
||||
$this->restore_locale();
|
||||
}
|
||||
|
||||
|
|
|
@ -70,6 +70,8 @@ class WC_Email_Customer_On_Hold_Order extends WC_Email {
|
|||
* @param WC_Order $order Order object.
|
||||
*/
|
||||
public function trigger( $order_id, $order = false ) {
|
||||
$this->setup_locale();
|
||||
|
||||
if ( $order_id && ! is_a( $order, 'WC_Order' ) ) {
|
||||
$order = wc_get_order( $order_id );
|
||||
}
|
||||
|
@ -81,12 +83,10 @@ class WC_Email_Customer_On_Hold_Order extends WC_Email {
|
|||
$this->placeholders['{order_number}'] = $this->object->get_order_number();
|
||||
}
|
||||
|
||||
if ( ! $this->is_enabled() || ! $this->get_recipient() ) {
|
||||
return;
|
||||
if ( $this->is_enabled() && $this->get_recipient() ) {
|
||||
$this->send( $this->get_recipient(), $this->get_subject(), $this->get_content(), $this->get_headers(), $this->get_attachments() );
|
||||
}
|
||||
|
||||
$this->setup_locale();
|
||||
$this->send( $this->get_recipient(), $this->get_subject(), $this->get_content(), $this->get_headers(), $this->get_attachments() );
|
||||
$this->restore_locale();
|
||||
}
|
||||
|
||||
|
|
|
@ -72,6 +72,8 @@ class WC_Email_Customer_Processing_Order extends WC_Email {
|
|||
* @param WC_Order $order Order object.
|
||||
*/
|
||||
public function trigger( $order_id, $order = false ) {
|
||||
$this->setup_locale();
|
||||
|
||||
if ( $order_id && ! is_a( $order, 'WC_Order' ) ) {
|
||||
$order = wc_get_order( $order_id );
|
||||
}
|
||||
|
@ -83,12 +85,10 @@ class WC_Email_Customer_Processing_Order extends WC_Email {
|
|||
$this->placeholders['{order_number}'] = $this->object->get_order_number();
|
||||
}
|
||||
|
||||
if ( ! $this->is_enabled() || ! $this->get_recipient() ) {
|
||||
return;
|
||||
if ( $this->is_enabled() && $this->get_recipient() ) {
|
||||
$this->send( $this->get_recipient(), $this->get_subject(), $this->get_content(), $this->get_headers(), $this->get_attachments() );
|
||||
}
|
||||
|
||||
$this->setup_locale();
|
||||
$this->send( $this->get_recipient(), $this->get_subject(), $this->get_content(), $this->get_headers(), $this->get_attachments() );
|
||||
$this->restore_locale();
|
||||
}
|
||||
|
||||
|
|
|
@ -149,6 +149,7 @@ class WC_Email_Customer_Refunded_Order extends WC_Email {
|
|||
* @param int $refund_id
|
||||
*/
|
||||
public function trigger( $order_id, $partial_refund = false, $refund_id = null ) {
|
||||
$this->setup_locale();
|
||||
$this->partial_refund = $partial_refund;
|
||||
$this->id = $this->partial_refund ? 'customer_partially_refunded_order' : 'customer_refunded_order';
|
||||
|
||||
|
@ -165,12 +166,10 @@ class WC_Email_Customer_Refunded_Order extends WC_Email {
|
|||
$this->refund = false;
|
||||
}
|
||||
|
||||
if ( ! $this->is_enabled() || ! $this->get_recipient() ) {
|
||||
return;
|
||||
if ( $this->is_enabled() && $this->get_recipient() ) {
|
||||
$this->send( $this->get_recipient(), $this->get_subject(), $this->get_content(), $this->get_headers(), $this->get_attachments() );
|
||||
}
|
||||
|
||||
$this->setup_locale();
|
||||
$this->send( $this->get_recipient(), $this->get_subject(), $this->get_content(), $this->get_headers(), $this->get_attachments() );
|
||||
$this->restore_locale();
|
||||
}
|
||||
|
||||
|
|
|
@ -88,21 +88,20 @@ class WC_Email_Customer_Reset_Password extends WC_Email {
|
|||
* @param string $reset_key
|
||||
*/
|
||||
public function trigger( $user_login = '', $reset_key = '' ) {
|
||||
$this->setup_locale();
|
||||
|
||||
if ( $user_login && $reset_key ) {
|
||||
$this->object = get_user_by( 'login', $user_login );
|
||||
|
||||
$this->user_login = $user_login;
|
||||
$this->reset_key = $reset_key;
|
||||
$this->user_email = stripslashes( $this->object->user_email );
|
||||
$this->recipient = $this->user_email;
|
||||
}
|
||||
|
||||
if ( ! $this->is_enabled() || ! $this->get_recipient() ) {
|
||||
return;
|
||||
if ( $this->is_enabled() && $this->get_recipient() ) {
|
||||
$this->send( $this->get_recipient(), $this->get_subject(), $this->get_content(), $this->get_headers(), $this->get_attachments() );
|
||||
}
|
||||
|
||||
$this->setup_locale();
|
||||
$this->send( $this->get_recipient(), $this->get_subject(), $this->get_content(), $this->get_headers(), $this->get_attachments() );
|
||||
$this->restore_locale();
|
||||
}
|
||||
|
||||
|
|
|
@ -72,6 +72,8 @@ class WC_Email_Failed_Order extends WC_Email {
|
|||
* @param WC_Order $order Order object.
|
||||
*/
|
||||
public function trigger( $order_id, $order = false ) {
|
||||
$this->setup_locale();
|
||||
|
||||
if ( $order_id && ! is_a( $order, 'WC_Order' ) ) {
|
||||
$order = wc_get_order( $order_id );
|
||||
}
|
||||
|
@ -82,12 +84,10 @@ class WC_Email_Failed_Order extends WC_Email {
|
|||
$this->placeholders['{order_number}'] = $this->object->get_order_number();
|
||||
}
|
||||
|
||||
if ( ! $this->is_enabled() || ! $this->get_recipient() ) {
|
||||
return;
|
||||
if ( $this->is_enabled() && $this->get_recipient() ) {
|
||||
$this->send( $this->get_recipient(), $this->get_subject(), $this->get_content(), $this->get_headers(), $this->get_attachments() );
|
||||
}
|
||||
|
||||
$this->setup_locale();
|
||||
$this->send( $this->get_recipient(), $this->get_subject(), $this->get_content(), $this->get_headers(), $this->get_attachments() );
|
||||
$this->restore_locale();
|
||||
}
|
||||
|
||||
|
|
|
@ -76,6 +76,8 @@ class WC_Email_New_Order extends WC_Email {
|
|||
* @param WC_Order $order Order object.
|
||||
*/
|
||||
public function trigger( $order_id, $order = false ) {
|
||||
$this->setup_locale();
|
||||
|
||||
if ( $order_id && ! is_a( $order, 'WC_Order' ) ) {
|
||||
$order = wc_get_order( $order_id );
|
||||
}
|
||||
|
@ -86,12 +88,10 @@ class WC_Email_New_Order extends WC_Email {
|
|||
$this->placeholders['{order_number}'] = $this->object->get_order_number();
|
||||
}
|
||||
|
||||
if ( ! $this->is_enabled() || ! $this->get_recipient() ) {
|
||||
return;
|
||||
if ( $this->is_enabled() && $this->get_recipient() ) {
|
||||
$this->send( $this->get_recipient(), $this->get_subject(), $this->get_content(), $this->get_headers(), $this->get_attachments() );
|
||||
}
|
||||
|
||||
$this->setup_locale();
|
||||
$this->send( $this->get_recipient(), $this->get_subject(), $this->get_content(), $this->get_headers(), $this->get_attachments() );
|
||||
$this->restore_locale();
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue