• I have two shipping methods in my WooCommerce shop, one is local pickup and the other standard postal rates(weight and country based). But for some reason WooCommerce selects local pickup as the default shipping method, but I want the weight and country based shipping to be selected by default. Since most users should use this option.

    How can I make WooCommerce to use the one shipping method instead of the other as default?

Viewing 9 replies - 1 through 9 (of 9 total)
  • you should be able to go to your main shipping tab in woo commerce ‘settings’ you’ll see a drag & drop bar with all shipping methods listed, drag your preferred one to the top, and put your active ones in order as you want them to appear, the one at top should be your default.
    Also make sure you’ve got the default button checked on the option you want.

    edit – i’ve also found if you choose ‘select boxes’ as your display for shipping it works a bit better.

    Thread Starter simenschi

    (@simenschi)

    That was what I thought, but it selects the “local pickup” even though it’s not on top, and the same result when I choose to use “Select Box”.

    Maybe it’s because “local pickup” is free, and WooCommerce automatically selects the cheapest alternative?

    Hi,

    did you manage to solve this issue? I’m facing the same problem with local_pickup being selected by default, regardless of the settings. Thanks!

    Thread Starter simenschi

    (@simenschi)

    No, sorry. Let me know if you find a solution!

    Hey,

    I actually managed to solve it. I’ll describe what I did in detail below, hopefully you’ll make it work too.

    I have two shipping methods enabled:
    – local delivery (fixed amount)
    – local pickup (free)
    On the shipping options panel I have them arranged in this order (as above), with the radio button checked for local delivery.
    With this setup I was having the exact same problem as you, on the checkout page local pickup was selected by default.
    This is what did the trick: on the local delivery panel (under the Shipping tab) I edited the title (to something like Local Delivery to your Address) and hit Save Changes.
    That’s it. I know it’s strange, maybe there’s a glitch somewhere, but it works flawlessly and local delivery is always checked by default during checkout.
    Try and do the same thing for the shipping method you’d like to be selected by default.

    Hope this helps.

    Inside /wp-content/plugins/woocommerce/includes/ there is a file called class-wc-shipping.php

    Search for the following code…

    if ( empty( $chosen_method ) || ! isset( $_available_methods[ $chosen_method ] ) ) {
    // Default to cheapest
    foreach ( $_available_methods as $method_id => $method ) {
    if ( $method->cost < $_cheapest_cost || ! is_numeric( $_cheapest_cost ) ) {
    $_cheapest_cost = $method->cost;
    $_cheapest_method = $method_id;
    }
    }
    $chosen_method = $_cheapest_method;
    }

    This forces the cheapest shipping method to be selected by default.

    My client wanted the most expensive option selected, so I switched the < to a >

    if ( empty( $chosen_method ) || ! isset( $_available_methods[ $chosen_method ] ) ) {
    						// Default to cheapest
    						foreach ( $_available_methods as $method_id => $method ) {
    							if ( $method->cost > $_cheapest_cost || ! is_numeric( $_cheapest_cost ) ) {
    								$_cheapest_cost 	= $method->cost;
    								$_cheapest_method 	= $method_id;
    							}
    						}
    						$chosen_method = $_cheapest_method;
    					}

    To clarify…

    $method->cost < $_cheapest_cost

    change to

    $method->cost > $_cheapest_cost

    This should work for you, but just remember to make a note of your changes, because updating WooCommerce will write over your changes.

    is there any possibility of doing this from the theme’s functions.php via a hook … or any way to avoid hacking the woocommerce core

    Very odd solution, but …. ovinic’s method above worked for me! Followed it exactly.

    Thanks for posting!

    Just tried this too. For some reason when it’s sepose to pick up another shipping weight then the default, it set it to pick up by default. After applying the same change, it picks up the middle option (which is the most expensive shipping option). Which confuses me even more :S

Viewing 9 replies - 1 through 9 (of 9 total)
  • The topic ‘[WooCommerce] how to select default shipping method’ is closed to new replies.