Skip to content
Advertisement

Trigger email on order custom status change in Woocommerce

I’ve created a custom email class and added it to WooCommerce. When I go to the emails setting in WooCommerce I can see my template there and when I trigger it manually the email arrives at the target email account. Now I have the problem that I’ve added a action to my class which should detect the order status change and do my trigger function if the order gets set to my custom status:

add_action( ‘woocommerce_order_status_wc-test-in-progress’, array( $this, ‘trigger’ ), 10, 10 );

But when I change the order to this status I don’t receive any email. Whats wrong here?

https://github.com/woocommerce/woocommerce/blob/master/includes/emails/class-wc-email-customer-on-hold-order.php

You can checkout this file. I’ve exactly did the same like in this file but replaced all triggers with my custom trigger on order status change.

Advertisement

Answer

Wen using woocommerce_order_status_{$status_transition[to]} composite hook, you just need to remove wc- from the status slug like:

add_action( 'woocommerce_order_status_test-in-progress', array( $this, 'trigger' ), 10, 10 );

And it should work.

User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement