WordPress.org

Forums

WooCommerce - excelling eCommerce
Woocommerce How to change default order status for cash on delivery payment gate (5 posts)

  1. manuelrossoni
    Member
    Posted 1 year ago #

    Hi all,

    if you pay an order with cash on delivery (payment gateway cod), woocommerce set the order as "on-hold" status.
    I need to set the status for new orders as "pending".

    Anyone can help me?

    Thanks in advance.
    Manuel

    http://wordpress.org/plugins/woocommerce/

  2. ADvi
    Member
    Posted 1 year ago #

    Same for me. Waiting for the solution...

  3. AnandSOFG
    Member
    Posted 8 months ago #

    function set_default_order( $order_id ){
    global $woocommerce;
    if ( !$order_id ) return;
    $order = new WC_Order( $order_id );
    $ar = get_term_by( 'id', $termid, 'shop_order_status'); // pass here term id of the pending status.
    $order->update_status($ar->slug);
    }
    add_action( 'woocommerce_thankyou', 'set_default_order' );

  4. ramedia
    Member
    Posted 8 months ago #

    @AnandSOFG

    Could you explain your code above. I don't see how this changes the default order status. Better yet, just post an example of changing the order status from "on-hold" to "processing". Thanks for your help,

  5. ramedia
    Member
    Posted 8 months ago #

    I found this code. Put it in your theme's functions.php:

    This will change the status of all new orders to "processing". You can change that status to any other. Note: this auto updates all order status' on new order, so if you are using multiple payment methods, you might not want to use this as it might screw up your defaults on other payment methods. I'm only using cheque, so I want all new orders to enter as "processing" instead of "on-hold."

    /* Reset status of new orders from "on-hold" to "processing" */
    add_action( 'woocommerce_thankyou', 'custom_woocommerce_auto_complete_order' );
    function custom_woocommerce_auto_complete_order( $order_id ) {
        global $woocommerce;
         if ( !$order_id )
            return;
        $order = new WC_Order( $order_id );
        $order->update_status( 'processing' );
    }

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic