Fix and standardize e-mail sending

This commit is contained in:
Claudiu Lodromanean 2017-02-09 14:49:39 -08:00
parent feeb98e801
commit ab8fb48bb4
3 changed files with 8 additions and 8 deletions

View File

@ -130,7 +130,7 @@ class WC_Meta_Box_Order_Actions {
if ( ! empty( $mails ) ) { if ( ! empty( $mails ) ) {
foreach ( $mails as $mail ) { foreach ( $mails as $mail ) {
if ( $mail->id == $email_to_send ) { if ( $mail->id == $email_to_send ) {
$mail->trigger( $order->get_id() ); $mail->trigger( $order->get_id(), $order );
/* translators: %s: email title */ /* translators: %s: email title */
$order->add_order_note( sprintf( __( '%s email notification manually sent.', 'woocommerce' ), $mail->title ), false, true ); $order->add_order_note( sprintf( __( '%s email notification manually sent.', 'woocommerce' ), $mail->title ), false, true );
} }

View File

@ -260,7 +260,12 @@ class WC_Emails {
*/ */
public function customer_invoice( $order ) { public function customer_invoice( $order ) {
$email = $this->emails['WC_Email_Customer_Invoice']; $email = $this->emails['WC_Email_Customer_Invoice'];
$email->trigger( $order );
if ( ! is_object( $order ) ) {
$order = wc_get_order( absint( $order ) );
}
$email->trigger( $order->get_id(), $order );
} }
/** /**

View File

@ -65,12 +65,7 @@ class WC_Email_Customer_Invoice extends WC_Email {
* *
* @param int|WC_Order $order * @param int|WC_Order $order
*/ */
public function trigger( $order ) { public function trigger( $order_id, $order ) {
if ( ! is_object( $order ) ) {
$order = wc_get_order( absint( $order ) );
}
if ( $order ) { if ( $order ) {
$this->object = $order; $this->object = $order;
$this->recipient = $this->object->get_billing_email(); $this->recipient = $this->object->get_billing_email();