Andrea Rinaldi
Andrea Rinaldi

Reputation: 11

Disable radio buttons default in Woocommerce

Sorry for my English. Can I disable the default choice radio buttons for shipping costs and payments in Woocommerce? I would like to have radio buttons blank. In short, the radio buttons are activated only when the user clicks. If a user does not fill in, example, the radio button of the shipment will go a window "Attention, choose the method of delivery." I hope I was clear. Thank you very much!

Upvotes: 1

Views: 3246

Answers (2)

mujuonly
mujuonly

Reputation: 11861

You can try this code snippet

// To test this code, open a private/incognito window,
   add an item to the cart and then go to cart page.
// Once an option is choosen, it will be the default option 
   from that moment onwards.

// Code to clear default shipping option.
add_filter( 'woocommerce_shipping_chosen_method', '__return_false');

Upvotes: 2

lartan
lartan

Reputation: 59

WooCommerce automatically chooses the cheapest shipping method available if you do not have a default setup.

https://i.sstatic.net/XCm8a.png

See the Automatic option at the bottom of the Shipping Methods section? That ensures that it would always choose a radio button.

I'm not saying this is impossible, but it would involve changing the underlying code.

May I know the reason behind not having a default option set? It sounds inefficient in my opinion. If the user does not like the default option, they can easily change it. At least this way, you no longer have to worry about putting in a "Please Choose A Shipping Method" validation.

The default shipping saves clicks for most of your clients especially if you pick the right option as default. The least clicks the better. ;)

Cheers!

As an update based on our discussion below, here's an option to hide the default shipping option...

Say "Free Shipping" is the default option. All you have to do is to add this code to your css...

#shipping_method_0_free_shipping{
display:none !important;
}

Then, the WooCommerce>Settings>Shipping Methods dashboard, remove the "Free Shipping" label and change it to a "." (if you make it blank, this will not work) so that no label will appear after the shipping button is handled.

However, this just makes sure that the default shipping method does not appear to the user.

https://i.sstatic.net/rX8tL.png

The system will still consider it existing. You still need to prevent the checkout from proceeding if "Free Shipping" was the chosen shipping method.

Upvotes: 0

Related Questions