Running E-Commerce Online shopping website with WordPress most popular WooCommerce plugin and have more than one Shipping Options facility which allow Customer to select their preferred Shopping according their need. You may also looking to change by Default selected Shipping option another instead of current default selected which is more suitable for you.
With use of Following code you able to change by default Shipping option selected with WooCommerce on 1st page Cart page getting loaded.
Add code in active theme functions.php file and $preferences array you need to set your used Shipping method IDs which you want set Default selected.
# function wdo_woocommerce_shipping_default_method( $method, $available_methods ) { // Don't do anything if a method is already selected. if ( ! empty( $method ) ) { return $method;} // in some case you may need to comment this line // Get the IDs of the methods that are available for Shipping options. $methods = array_keys( $available_methods ); $preferences = array( 'shipping-method-id-1', 'shipping-method-id-2', ); // Check the preferred options and return it if it's available shipping option. foreach ( $preferences as $preference ) { if ( in_array( $preference, $methods ) ) { return $preference; } } return $method; } add_filter( 'woocommerce_shipping_chosen_method', 'wdo_woocommerce_shipping_default_method', 10, 2 ); #