• Resolved Alahyane Said

    (@alahyane)


    Hi everyone,

    How can I automatically make every new Woocommerce order’s status in hold.
    Every time I get a new order the status is automatically “processing” but I don’t want that.

    Please let me know how I can change that.

    Thanks,
    Alahyane

Viewing 6 replies - 1 through 6 (of 6 total)
  • /**
    * Auto On hold all WooCommerce orders.
    */
    function custom_woocommerce_auto_complete_order( $order_id ) {
        if ( ! $order_id ) {
            return;
        }
    
        $order = wc_get_order( $order_id );
        if( 'processing'== $order->get_status() ) {
            $order->update_status( 'on-hold' );
        }
    }
    add_action( 'woocommerce_payment_complete', 'custom_woocommerce_auto_complete_order' );
    Thread Starter Alahyane Said

    (@alahyane)

    Helo @mohitmishra

    Thanks for your response. I’ve actually added the code you have provided to my functions.php file of the child theme but it didn’t work ??

    I’m still getting incoming Woocommerce orders status as ‘Processing’ unfortunately!

    Hello @alahyane Try this code I am sure this will help you paste this code into your themes’s functions.php

    /**
    * Auto On hold all WooCommerce orders.
    */
    function custom_woocommerce_auto_complete_order( $order_id ) {
        if ( ! $order_id ) {
            return;
        }
    
        $order = wc_get_order( $order_id );
        if( 'processing'== $order->get_status() ) {
            $order->update_status( 'processing' );
        }
    }
    add_action( 'woocommerce_thankyou', 'custom_woocommerce_auto_complete_order' );
    Thread Starter Alahyane Said

    (@alahyane)

    Hi @mohitmishra

    I really wish I could say it worked but it didn’t, unfortunately!
    I tried this code on two websites but each time the order status is always “Processing”!

    I don’t know if this may help but orders on my website are placed without the need for payment. The customer will have to pay upon delivery.

    Thank you,
    Alahyane

    Ohh sorry my fault @alahyane This is tested code this will help you

    /**
    * Auto On hold all WooCommerce orders.
    */
    function custom_woocommerce_auto_complete_order( $order_id ) {
        if ( ! $order_id ) {
            return;
        }
    
        $order = wc_get_order( $order_id );
        if( 'processing'== $order->get_status() ) {
            $order->update_status( 'on-hold' );
        }
    }
    add_action( 'woocommerce_thankyou', 'custom_woocommerce_auto_complete_order' );
    Thread Starter Alahyane Said

    (@alahyane)

    Helloo @mohitmishra

    I’ve tested it and it worked, thank you so much ??
    Now when an order is placed it automatically goes in hold!

    Thanks again,
    Alahyane

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Set new order’s status automatically in hold!’ is closed to new replies.