Created
June 24, 2025 11:54
-
-
Save xlplugins/e6ddae8c93414a74003d7642fb25b579 to your computer and use it in GitHub Desktop.
Shipping Method validtions
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
add_action( 'woocommerce_checkout_process', 'force_choose_shipping_method' ); | |
function force_choose_shipping_method() { | |
if ( WC()->cart->needs_shipping() ) { | |
$chosen_method = WC()->session->get( 'chosen_shipping_methods' ); | |
if ( empty( $chosen_method ) || empty( $chosen_method[0] ) ) { | |
wc_add_notice( __( 'Please select a shipping method to proceed.', 'woocommerce' ), 'error' ); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment