Set “flat rate” shipping method as default in woocommerce
问题 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 (selected) in the cart or checkout page. Any help should be appreciated. 回答1: 1) You can use the following code (to set "flat rate" shipping method as default) In cart page: add_action( 'woocommerce_before_cart', 'set_default_chosen_shipping_method', 5 ); function set_default_chosen_shipping_method(){ // if( count( WC()->session->get(