Backwards compatibility for triggers

Closes #13141
This commit is contained in:
Mike Jolley 2017-02-10 13:09:37 +00:00
parent 5349171083
commit b58e26b0ab
7 changed files with 65 additions and 36 deletions

View File

@ -43,13 +43,17 @@ class WC_Email_Cancelled_Order extends WC_Email {
}
/**
* Trigger.
* Trigger the sending of this email.
*
* @param int $order_id
* @param WC_Order $order
* @param int $order_id The order ID.
* @param WC_Order $order Order object.
*/
public function trigger( $order_id, $order ) {
if ( $order ) {
public function trigger( $order_id, $order = false ) {
if ( $order_id && ! is_a( $order, 'WC_Order' ) ){
$order = wc_get_order( $order_id );
}
if ( is_a( $order, 'WC_Order' ) ) {
$this->object = $order;
$this->find['order-date'] = '{order_date}';
$this->find['order-number'] = '{order_number}';

View File

@ -47,13 +47,17 @@ class WC_Email_Customer_Completed_Order extends WC_Email {
}
/**
* Trigger.
* Trigger the sending of this email.
*
* @param int $order_id
* @param WC_Order $order
* @param int $order_id The order ID.
* @param WC_Order $order Order object.
*/
public function trigger( $order_id, $order ) {
if ( $order ) {
public function trigger( $order_id, $order = false ) {
if ( $order_id && ! is_a( $order, 'WC_Order' ) ){
$order = wc_get_order( $order_id );
}
if ( is_a( $order, 'WC_Order' ) ) {
$this->object = $order;
$this->recipient = $this->object->get_billing_email();

View File

@ -61,12 +61,17 @@ class WC_Email_Customer_Invoice extends WC_Email {
}
/**
* Trigger.
* Trigger the sending of this email.
*
* @param int|WC_Order $order
* @param int $order_id The order ID.
* @param WC_Order $order Order object.
*/
public function trigger( $order_id, $order ) {
if ( $order ) {
public function trigger( $order_id, $order = false ) {
if ( $order_id && ! is_a( $order, 'WC_Order' ) ){
$order = wc_get_order( $order_id );
}
if ( is_a( $order, 'WC_Order' ) ) {
$this->object = $order;
$this->recipient = $this->object->get_billing_email();

View File

@ -41,13 +41,17 @@ class WC_Email_Customer_On_Hold_Order extends WC_Email {
}
/**
* Trigger.
* Trigger the sending of this email.
*
* @param int $order_id
* @param WC_Order $order
* @param int $order_id The order ID.
* @param WC_Order $order Order object.
*/
public function trigger( $order_id, $order ) {
if ( $order ) {
public function trigger( $order_id, $order = false ) {
if ( $order_id && ! is_a( $order, 'WC_Order' ) ){
$order = wc_get_order( $order_id );
}
if ( is_a( $order, 'WC_Order' ) ) {
$this->object = $order;
$this->recipient = $this->object->get_billing_email();

View File

@ -41,13 +41,17 @@ class WC_Email_Customer_Processing_Order extends WC_Email {
}
/**
* Trigger.
* Trigger the sending of this email.
*
* @param int $order_id
* @param WC_Order $order
* @param int $order_id The order ID.
* @param WC_Order $order Order object.
*/
public function trigger( $order_id, $order ) {
if ( $order ) {
public function trigger( $order_id, $order = false ) {
if ( $order_id && ! is_a( $order, 'WC_Order' ) ){
$order = wc_get_order( $order_id );
}
if ( is_a( $order, 'WC_Order' ) ) {
$this->object = $order;
$this->recipient = $this->object->get_billing_email();

View File

@ -7,7 +7,7 @@ if ( ! defined( 'ABSPATH' ) ) {
if ( ! class_exists( 'WC_Email_Failed_Order' ) ) :
/**
* Failed Order Email
* Failed Order Email.
*
* An email sent to the admin when payment fails to go through.
*
@ -20,7 +20,7 @@ if ( ! class_exists( 'WC_Email_Failed_Order' ) ) :
class WC_Email_Failed_Order extends WC_Email {
/**
* Constructor
* Constructor.
*/
public function __construct() {
$this->id = 'failed_order';
@ -43,13 +43,17 @@ class WC_Email_Failed_Order extends WC_Email {
}
/**
* Trigger.
* Trigger the sending of this email.
*
* @param int $order_id
* @param WC_Order $order
* @param int $order_id The order ID.
* @param WC_Order $order Order object.
*/
public function trigger( $order_id, $order ) {
if ( $order ) {
public function trigger( $order_id, $order = false ) {
if ( $order_id && ! is_a( $order, 'WC_Order' ) ){
$order = wc_get_order( $order_id );
}
if ( is_a( $order, 'WC_Order' ) ) {
$this->object = $order;
$this->find['order-date'] = '{order_date}';
$this->find['order-number'] = '{order_number}';

View File

@ -47,13 +47,17 @@ class WC_Email_New_Order extends WC_Email {
}
/**
* Trigger.
* Trigger the sending of this email.
*
* @param int $order_id
* @param WC_Order $order
* @param int $order_id The order ID.
* @param WC_Order $order Order object.
*/
public function trigger( $order_id, $order ) {
if ( $order ) {
public function trigger( $order_id, $order = false ) {
if ( $order_id && ! is_a( $order, 'WC_Order' ) ){
$order = wc_get_order( $order_id );
}
if ( is_a( $order, 'WC_Order' ) ) {
$this->object = $order;
$this->find['order-date'] = '{order_date}';
$this->find['order-number'] = '{order_number}';