• Resolved Daryl Malibiran

    (@darylmalibiran)


    Hi,

    I have the same issue as this one but none of the solutions worked on my end.

    I’m just wondering if there are any internal changes in the WooCommerce plugin that makes the code snippet add_filter( 'woocommerce_shipping_chosen_method', '__return_false', 99); to stop working.

    Thanks!

Viewing 2 replies - 1 through 2 (of 2 total)
  • Hi @darylmalibiran

    // Validate shipping method fields and returning an error if none is choosed
    add_action( 'woocommerce_checkout_process', 'shipping_method_validation', 20 );
    function shipping_method_validation() {
        if ( ! isset( $_POST['shipping_method[0]'] ) ){
            wc_add_notice( __( "You need to choose your a shipping option.", "woocommerce" ), 'error' );
        }
    }

    Code goes in function.php file of your active child theme (or active theme). Tested and works.

    Thanks
    Ahir Hemant

    Mirko P.

    (@rainfallnixfig)

    Hi @darylmalibiran,

    We haven’t heard from you in a while, so I’m going to mark this as resolved. Feel free to start a new thread if you have any more questions.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Force user to select the default and only shipping method before checkout’ is closed to new replies.