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

How to Change WooCommerce Order Status for Orders Placed from Specific Countries?

Change WooCommerce Order Status Based on Country

If an online retailer is selling products worldwide, then it is a good practice to manage order statuses effectively. This will help store owners to quickly identify the order placed from a particular country and so they can act promptly.

This customization of changing the WooCommerce order status to a new status can be also done by creating a custom WoCommerce order status and assigning it to a specific billing country. But here we will look into updating the default status to the status that you prefer just by changing the label of the default status.

Solution: Change WooCommerce Order Status Based on Country

The code snippet will help to change the status of orders placed from a specific country such as ‘India’ to the status of ‘scheduled’.

add_action('woocommerce_order_status_changed', 'ts_change_status_by_country');

function ts_change_status_by_country($order_id)
{
    if (!$order_id) {
        return;
    }

    // Get the order object
    $order = wc_get_order($order_id);

    // Get the billing country of the customer
    $billing_country = $order->get_billing_country();

    // Check if the billing country is 'IN' (India)
    if ($billing_country == 'IN') {
        // If the billing country is not 'IN', update the order status to 'completed'
        $order->update_status('completed');
    }
}
add_filter( 'wc_order_statuses', 'ts_rename_order_status_msg', 20, 1 );
function ts_rename_order_status_msg( $order_statuses ) {
$order_statuses['wc-completed'] = _x( 'Scheduled', 'Order status', 'woocommerce' );


return $order_statuses;
}

Output

When a customer places an order from the billing country of ‘India’ the order status immediately gets changed to ‘scheduled’ on the orders page of the admin.

How to Change WooCommerce Order Status for Orders Placed from Specific Countries? - Tyche Softwares

Customers from the country ‘India’ when viewing their orders on the front end will likely know that their orders are been ‘scheduled’.

How to Change WooCommerce Order Status for Orders Placed from Specific Countries? - Tyche Softwares

Alternatively, you can also change the status based on the payment method. I you need to explore more refert to this post that will automatically set the WooCommerce order status as Completed when they go to the processing status.

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

Share It:

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