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

How to Disable ‘Place Order’ Button for Specific Shipping Zone in WooCommerce?

The code snippet will help you to disable the “Place Order” button in WooCommerce for a specific shipping zone.

add_filter('woocommerce_order_button_html', 'ts_disable_place_order_button_html' );
function ts_disable_place_order_button_html( $button ) {
    // HERE define your targeted shipping zone
    $targeted_zone_name = "India";

    // Get the chosen shipping method (if it exist)
    $chosen_shipping_methods = WC()->session->get( 'chosen_shipping_methods' );
    $chosen_shipping_method  = reset($chosen_shipping_methods);
    $chosen_shipping_method  = explode(':', $chosen_shipping_method );
    $chosen_shipping_zone    = WC_Shipping_Zones::get_zone_by( 'instance_id', end($chosen_shipping_method) );

    // If the targeted shipping zone is found, disable the button
    if( $targeted_zone_name == $chosen_shipping_zone->get_zone_name() ) {
        $style  = 'style="background:Silver !important; color:white !important; cursor: not-allowed !important; text-align:center;"';
        $text   = apply_filters( 'woocommerce_order_button_text', __( 'Place order', 'woocommerce' ) );
        $button = '<a class="button" '.$style.'>' . $text . '</a>';
    }
    return $button;
}

Output

In the below output, when the customer chooses the Zone ‘India’ the place order button gets disabled. If any other zone is selected the place order button will be clickable, thus allowing customers to proceed on placing the order.


How to Disable 'Place Order' Button for Specific Shipping Zone in WooCommerce?

Based on specific requirements you can disable or remove such buttons from your store.Similarly, you can also remove proceed to checkout button from cart page in WooCommerce.

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