WooCommerce: Need on-hold email notidfication when status changes.

On my site: http://so+++s.com/

There's a Woocommerce section, i want to be able to change the order status from completed to on hold and this says you ca do it on line 42

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

added the lines for status compled (as in screenshot)

https://static.livechatinc.com/8801096/P8HEJZ6ZD7/0f2b2806196b6607e24e3f4323da094a/Screen%20Shot%202018-05-08%20at%2016.19.44.png

But still, only emails are sending for cancelled & not on-hold status.

  • Nahid

    Hey allanlove !
    Hope you are having a great day!

    You can add the following code to your theme's (most preferably, child theme's) functions.php file in order to send notification when order status changes from "Completed" to "On hold":

    add_filter( 'woocommerce_email_actions', 'add_another_email_action' );
    function add_another_email_action( $array ) {
    	$array[]='woocommerce_order_status_completed_to_on-hold';
        return $array;
    }
    add_action( 'woocommerce_email', 'hook_another_email_on_hold' );
    function hook_another_email_on_hold( $email_class ) {
    	add_action( 'woocommerce_order_status_completed_to_on-hold_notification', array( $email_class->emails['WC_Email_Customer_On_Hold_Order'], 'trigger' ) );
    }

    Alternatively, you can also put the code in a mu-plugin. That'll require you to paste the mentioned code in a PHP file that ends with the extension .php, e.g. "anyname.php". The mentioned code must have a "<?php" definition at the start of the file. This PHP file should be placed in {your root WordPress folder}/wp-content/mu-plugins (you'll need to create the folder named "mu-plugins" if it is not there already).

    Note: It is not recommended to modify the code of a plugin as they might interfere with other sections or get overwritten on updates. Instead of modifying the WooCommerce plugin code, you can use the above mentioned custom code in order to achieve what you're looking for.

    Hope this helps. Let us know if this works for you. Thanks!

    Kind regards,
    Nahid

  • Nahid

    Hey allanlove !
    Hope you are doing well today!

    Sorry to hear that the code didn't work for you. I got this tested by a colleague of mine in a clean installation with WooCommerce and a default WordPress theme and it worked for him. Could you try the following code instead with greater priorities just in case other plugins or the theme in your site are using the same hooks/filters?

    add_filter( 'woocommerce_email_actions', 'add_another_email_action', 9999 );
    function add_another_email_action( $array ) {
    	$array[]='woocommerce_order_status_completed_to_on-hold';
    	return $array;
    }
    add_action( 'woocommerce_email', 'hook_another_email_on_hold', 9999 );
    function hook_another_email_on_hold( $email_class ) {
    	add_action( 'woocommerce_order_status_completed_to_on-hold_notification', array( $email_class->emails['WC_Email_Customer_On_Hold_Order'], 'trigger' ) );
    }

    Hope this helps. Let us know if this works for you. Thanks!

    Kind regards,
    Nahid

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.