Black Friday & Cyber Monday SUPER SALE ALL WEEK:
Grab 40% OFF on plugins
Days
Hours
Minutes
Seconds

How to Change WooCommerce Order Status Based on Order Total?

Online store owners would typically provide offers and discounts to encourage customers to buy more. This is one way to convert customers as repeated customers. Similarly, you can prioritize shipping processing based on order total and change the order status accordingly.

For instance, if the customer purchases for an amount of above $500 and you would prefer to do expedited shipping for such orders. To distinguish these orders from the admin side you can auomatically update the status of such orders to processing or anything else as per your wish.

Solution: Change Order Status Based on Order Total

The code snippet will help you to change the order status to ‘processing’ if the order total exceeds the maximum total amount of $500 as defined in the code.

 add_action( 'woocommerce_thankyou', 'ts_auto_complete_processing_orders_based_on_total', 90, 1 );
function ts_auto_complete_processing_orders_based_on_total( $order_id ){
    if( ! $order = wc_get_order( $order_id ) ){
        return;
    }

    // HERE define the max total order amount
    $max_total_limit = 500;

    if( $order->has_status('on-hold') && $order->get_total() > $max_total_limit ){
        $order->update_status( 'processing' );
    }
}

Output

When orders are placed, the code checks for the total order amount and the current status of the order. If the order total exceeds the threshold amount ($max_total_limit = 500;) and if the current status is on-hold it will be automatically changed to the ‘processing’ status.

How to Change WooCommerce Order Status Based on Order Total? - Tyche Softwares

In the same way, you can also change WooCommerce order status for orders placed from specific countries.

Browse more in: Code Snippets, WooCommerce How Tos, WooCommerce Tutorials

Share It:

Subscribe
Notify of
0 Comments
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x