Set “flat rate” shipping method as default in woocommerce

前端 未结 2 1203
耶瑟儿~
耶瑟儿~ 2021-01-28 16:09

I have a woocommerce website and I have set 2 shipping methods:
- Flat Rate
- Local pickup

I would like to set the \"Flat rate\" shipping method as default (sel

2条回答
  •  迷失自我
    2021-01-28 16:53

    You could use the following code to set 'any' shipping method as default.

    function reset_default_shipping_method( $method, $available_methods ) {
        $default_method = 'wf_fedex_woocommerce_shipping:FEDEX_GROUND'; //provide the service name here
        if( array_key_exists($method, $available_methods ) )
            return $default_method;
        else
            return $method;
    }
    

    Let's say, you're using a Carrier shipping plugin like WooCommerce FedEx Shipping Plugin. You can fetch the value Id (shown below) and paste it under the '$default_method' in the above code.

    You will have to copy and paste the code in WordPress Dashboard->Appearance–>Editor–>functions.php of your theme.

    Hope that helped. :)

    copy the value Id from here

提交回复
热议问题