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.
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.