Viewing 9 replies - 1 through 9 (of 9 total)
  • Plugin Author Mike Jolley (a11n)

    (@mikejolley)

    What are you using to bulk edit here?

    Thread Starter tmleeek

    (@tmleeek)

    i only send email to my self when order status changed from processing to complete , however when that done with bulk action , and the rest will not sent

    Plugin Author Mike Jolley (a11n)

    (@mikejolley)

    Looking at the code, when you bulk edit it runs this per order:

    $order->update_status( $new_status, __( 'Order status changed by bulk edit:', 'woocommerce' ), true );

    So all events will be triggered.

    Thread Starter tmleeek

    (@tmleeek)

    this is th code i am using

    function cs_custom_status_messages( $order_id, $old_status, $new_status ) {
        global $woocommerce;
        if($old_status=="processing" && $new_status=="completed"){
          echo $order_id;
        }
    }
    add_action( 'woocommerce_order_status_changed', 'cs_custom_status_messages', 1, 3 );

    however it only print one order not the rest

    Caleb Burks

    (@icaleb)

    Automattic Happiness Engineer

    When you bulk update, the change is getting logged in the order notes though: http://cld.wthms.co/1jdRM/3k9fIUwC?

    This is getting run first: https://github.com/woothemes/woocommerce/blob/master/includes/admin/class-wc-admin-post-types.php#L1464-L1465

    Followed by the hook you are using: https://github.com/woothemes/woocommerce/blob/master/includes/abstracts/abstract-wc-order.php#L2375-L2377

    It has to run for every order, else each order wouldn’t be getting that order note. My guess is that there is just a problem for how you are echoing the order id. Try logging to an external file for testing.

    Thread Starter tmleeek

    (@tmleeek)

    hello , can you give me example how can i do it correctly , and Mike please share me any example the correct way

    what the correct way by code please

    Thread Starter tmleeek

    (@tmleeek)

    so i play smart and try the edit action but its doesnt work

    check my code

    function test_mail($o_id,$new_status)
    {
    	mail("xxxxx@xxxxx.com","test bulk","$o_id");
    }
    add_action('woocommerce_order_edit_status','test_mail');

    Thread Starter tmleeek

    (@tmleeek)

    ok , its seems my mistak in the end , every thing is working now , i was including object in the loop in incorrect way thats was the problem from start .

    Caleb Burks

    (@icaleb)

    Automattic Happiness Engineer

    It works like it should….

    Try this:

    function cs_custom_status_messages( $order_id, $old_status, $new_status ) {
    	$order = new WC_Order( $order_id );
    
    	if ( $old_status=="processing" && $new_status=="completed" ){
    		$order->add_order_note( 'Testing 123');
    	}
    }
    add_action( 'woocommerce_order_status_changed', 'cs_custom_status_messages', 1, 3 );

    Set three orders to processing, and then bulk set them all to completed. It will add the order note to all of them: http://cld.wthms.co/1ecd/12XdJxxY

    We can’t help with customization like this. It is far beyond the scope of this support forum. If you can’t figure out the code you need, I’d recommend hiring a developer for help:

    http://jobs.wordpress.net/
    https://codeable.io/

Viewing 9 replies - 1 through 9 (of 9 total)
  • The topic ‘bulk change status filter or action’ is closed to new replies.