I’ve removed the default shipping method using
add_filter( 'woocommerce_shipping_chosen_method', '__return_false', 99);
I am trying to ‘disable’ the “proceed to checkout” button on the cart/basket page so that the customer is forced to select their required shipping method.
I tried to use the following snippet that I found on google;
add_action( 'woocommerce_proceed_to_checkout', 'modify_checkout_button_no_shipping', 1 );
function modify_checkout_button_no_shipping() {
$chosen_shipping_methods = WC()->session->get( 'chosen_shipping_methods' );
// removes empty values from the array
$chosen_shipping_methods = array_filter( $chosen_shipping_methods );
if ( empty( $chosen_shipping_methods ) ) {
remove_action( 'woocommerce_proceed_to_checkout', 'woocommerce_button_proceed_to_checkout', 20 );
echo '<a href="" class="checkout-button button alt disabled wc-forward">' . __("You must choose a shipping method", "woocommerce") . '</a>';
}
}
This works fine but what if I only want it to apply to zone 1 and 2 without it affecting other zones.
How do I alter the if statement to only apply the remove action to specifically zone 1 and 2 or in the reverse, how not to apply it to zones 3 and 4.
Thanks in advance for any help.