3

I need to send a customer email notification when I manually set order status from processing to on-hold status. I have added the following action hook into my functions.php file:

add_action( 'woocommerce_order_status_processing_to_on-hold_notification', array( $this, 'trigger' ), 10, 2 );

Its not working (not showing in WP Mail Log), even though this particular email notification is enabled in woocommerce settings and the similar hook as shown below is working just fine:

add_action( 'woocommerce_order_status_pending_to_on-hold_notification', array( $this, 'trigger' ), 10, 2 );

Environment: Woocommerce v.3.5.1 Wordpress v.4.9.9 PHP 5.6

Any help would be much appreciated.

LoicTheAztec
  • 229,944
  • 23
  • 356
  • 399
RWS
  • 538
  • 5
  • 14

1 Answers1

6

Updated the hook

You should try the following hooked function instead:

add_action( 'woocommerce_order_status_processing_to_on-hold', 'enable_processing_to_on_hold_notification', 10, 2 );
function enable_processing_to_on_hold_notification( $order_id, $order ){
    // Getting all WC_emails array objects
    $mailer = WC()->mailer()->get_emails();

    // Send the "On Hold" notification
    $mailer['WC_Email_Customer_On_Hold_Order']->trigger( $order_id );
}

Code goes in function.php file of your active child theme (active theme). It should works.

LoicTheAztec
  • 229,944
  • 23
  • 356
  • 399
  • 1
    You probably meant `add_action( 'woocommerce_order_status_processing_to_on-hold', 'send_custom_status_email_notification', 10, 2 );` When i adjusted it, It worked! Thank you! Please fix your answer and I will mark it as correct. – RWS Feb 18 '19 at 14:41
  • I'm afraid there is little mistake again: `function enable_processing_to_on-hold_notification( $order_id, $order ){` will throw error `unexpected "-"` in function name; – RWS Feb 18 '19 at 15:23
  • 1
    @RWS Updated… Sorry ;) – LoicTheAztec Feb 18 '19 at 15:31