WooCommerce Hook to Trigger Email in Refund inside Email Class -


by default, woocommerce not send refund emails because refunding is, mike jolley says, "a manual process". however, need send one!

my problem is: can't find hook fire inside extended email class this.

i followed tutorial, wrote class extend wc_email , got working except need hook trigger class when order status changed , saved "refunded":

http://www.skyverge.com/blog/how-to-add-a-custom-woocommerce-email/

i tried various hooks woocommerce_order_status_refund in place of woocommerce_order_status_pending_to_processing_notification hook on line 39-40.

the problem woocommerce_order_status_refund doesn't trigger inside email class. works fine elsewhere, not in context.

i tried replacing hook woocommerce_order_actions_end sort of "generic". added if (! $order->status == 'refunded') filter "refunded" only. hook fired every time order status of 'refunded' loaded.

(i tried adding custom action woocommerce_order_actions actions menu, problem here don't know how trigger class this. seems load before class doesn't work either.)

is there way trigger email send via extended class when order status changed 'refunded'?

referencing question there 2 things must refund status trigger email.

first must register woocommerce_order_status_refunded hook hook trigger email. default, not.

/**  * register "woocommerce_order_status_refunded" hook necessary  * allow automatic email notifications when order changed refunded.  *   * @modified https://stackoverflow.com/a/26413223/2078474 remove anonymous function  */ add_action( 'woocommerce_init', 'so_25353766_register_email' ); function so_25353766_register_email(){     add_action( 'woocommerce_order_status_refunded', array( wc(), 'send_transactional_email' ), 10, 10 ); } 

edit woocommerce 2.3

after merging in pull request, next version of woocommerce (2.3) should support filtering of actions trigger emails. add refund status via filter:

add_filter( 'woocommerce_init', 'so_26483961_filter_email_actions' ); function so_26483961_filter_email_actions( $emails ){     $emails[] = 'woocommerce_order_status_refunded';     return $emails; } 

then in custom email class's _construct method, can use trigger:

add_action( 'woocommerce_order_status_refunded', array( $this, 'trigger' ) ); 

Comments

Popular posts from this blog

javascript - Jquery show_hide, what to add in order to make the page scroll to the bottom of the hidden field once button is clicked -

javascript - Highcharts multi-color line -

javascript - Enter key does not work in search box -