Improved refund email events and woocommerce_order_fully_refunded hook.
Closes #8793
This commit is contained in:
parent
a3eec05b0c
commit
f8b539eb5e
|
@ -69,7 +69,7 @@ class WC_Emails {
|
|||
'woocommerce_order_status_on-hold_to_processing',
|
||||
'woocommerce_order_status_on-hold_to_cancelled',
|
||||
'woocommerce_order_status_completed',
|
||||
'woocommerce_order_status_refunded',
|
||||
'woocommerce_order_fully_refunded',
|
||||
'woocommerce_order_partially_refunded',
|
||||
'woocommerce_new_customer_note',
|
||||
'woocommerce_created_customer'
|
||||
|
|
|
@ -22,22 +22,18 @@ class WC_Email_Customer_Refunded_Order extends WC_Email {
|
|||
/**
|
||||
* Constructor
|
||||
*/
|
||||
function __construct() {
|
||||
|
||||
public function __construct() {
|
||||
$this->set_email_strings();
|
||||
|
||||
// Triggers for this email
|
||||
add_action( 'woocommerce_order_status_refunded_notification', array( $this, 'trigger' ), null, 3 );
|
||||
add_action( 'woocommerce_order_partially_refunded_notification', array( $this, 'trigger' ), null, 3 );
|
||||
|
||||
add_action( 'woocommerce_order_fully_refunded_notification', array( $this, 'trigger_full' ), 10, 2 );
|
||||
add_action( 'woocommerce_order_partially_refunded_notification', array( $this, 'trigger_partial' ), 10, 2 );
|
||||
|
||||
// Call parent constuctor
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
function set_email_strings( $partial_refund = false ) {
|
||||
|
||||
|
||||
public function set_email_strings( $partial_refund = false ) {
|
||||
$this->subject_partial = $this->get_option( 'subject_partial', __( 'Your {site_title} order from {order_date} has been partially refunded', 'woocommerce' ) );
|
||||
$this->subject_full = $this->get_option( 'subject_full', __( 'Your {site_title} order from {order_date} has been refunded', 'woocommerce' ) );
|
||||
|
||||
|
@ -64,11 +60,24 @@ class WC_Email_Customer_Refunded_Order extends WC_Email {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Full refund notification
|
||||
*/
|
||||
public function trigger_full( $order_id, $refund_id = null ) {
|
||||
$this->trigger( $order_id, false, $refund_id );
|
||||
}
|
||||
|
||||
/**
|
||||
* Partial refund notification
|
||||
*/
|
||||
public function trigger_partial( $order_id, $refund_id = null ) {
|
||||
$this->trigger( $order_id, true, $refund_id );
|
||||
}
|
||||
|
||||
/**
|
||||
* Trigger.
|
||||
*/
|
||||
function trigger( $order_id, $partial_refund = false, $refund_id = null ) {
|
||||
|
||||
public function trigger( $order_id, $partial_refund = false, $refund_id = null ) {
|
||||
$this->partial_refund = $partial_refund;
|
||||
$this->set_email_strings( $partial_refund );
|
||||
|
||||
|
@ -102,7 +111,7 @@ class WC_Email_Customer_Refunded_Order extends WC_Email {
|
|||
* @access public
|
||||
* @return string
|
||||
*/
|
||||
function get_subject() {
|
||||
public function get_subject() {
|
||||
return apply_filters( 'woocommerce_email_subject_customer_refunded_order', $this->format_string( $this->subject ), $this->object );
|
||||
}
|
||||
|
||||
|
@ -112,7 +121,7 @@ class WC_Email_Customer_Refunded_Order extends WC_Email {
|
|||
* @access public
|
||||
* @return string
|
||||
*/
|
||||
function get_heading() {
|
||||
public function get_heading() {
|
||||
return apply_filters( 'woocommerce_email_heading_customer_refunded_order', $this->format_string( $this->heading ), $this->object );
|
||||
}
|
||||
|
||||
|
@ -122,7 +131,7 @@ class WC_Email_Customer_Refunded_Order extends WC_Email {
|
|||
* @access public
|
||||
* @return string
|
||||
*/
|
||||
function get_content_html() {
|
||||
public function get_content_html() {
|
||||
ob_start();
|
||||
wc_get_template( $this->template_html, array(
|
||||
'order' => $this->object,
|
||||
|
@ -140,7 +149,7 @@ class WC_Email_Customer_Refunded_Order extends WC_Email {
|
|||
*
|
||||
* @return string
|
||||
*/
|
||||
function get_content_plain() {
|
||||
public function get_content_plain() {
|
||||
ob_start();
|
||||
wc_get_template( $this->template_plain, array(
|
||||
'order' => $this->object,
|
||||
|
@ -156,7 +165,7 @@ class WC_Email_Customer_Refunded_Order extends WC_Email {
|
|||
/**
|
||||
* Initialise settings form fields.
|
||||
*/
|
||||
function init_form_fields() {
|
||||
public function init_form_fields() {
|
||||
$this->form_fields = array(
|
||||
'enabled' => array(
|
||||
'title' => __( 'Enable/Disable', 'woocommerce' ),
|
||||
|
|
|
@ -722,7 +722,15 @@ function wc_create_refund( $args = array() ) {
|
|||
$max_remaining_items = absint( $order->get_item_count() - $order->get_item_count_refunded() );
|
||||
|
||||
if ( $max_remaining_refund > 0 || $max_remaining_items > 0 ) {
|
||||
do_action( 'woocommerce_order_partially_refunded', $args['order_id'], true, $refund_id );
|
||||
/**
|
||||
* woocommerce_order_partially_refunded
|
||||
*
|
||||
* @since 2.4.0
|
||||
* Note: 3rd arg was added in err. Kept for bw compat. 2.4.3
|
||||
*/
|
||||
do_action( 'woocommerce_order_partially_refunded', $args['order_id'], $refund_id, $refund_id );
|
||||
} else {
|
||||
do_action( 'woocommerce_order_fully_refunded', $args['order_id'], $refund_id );
|
||||
}
|
||||
|
||||
do_action( 'woocommerce_refund_created', $refund_id, $args );
|
||||
|
|
|
@ -168,6 +168,7 @@ Yes you can! Join in on our [GitHub repository](http://github.com/woothemes/wooc
|
|||
* Fix - wc_get_product_variation_attributes should only get parent attributes which are for variations.
|
||||
* Tweak - Disable display_errors during ajax requests to prevent malformed JSON.
|
||||
* Tweak - When merging shipping taxes with a shipping rate taxes, ensure shipping rate taxes is not malformed.
|
||||
* Tweak - Improved refund email events and woocommerce_order_fully_refunded hook.
|
||||
|
||||
= 2.4.2 - 11/08/2015 =
|
||||
* Fix - If all variations are out of stock, maintain pricing display.
|
||||
|
|
Loading…
Reference in New Issue