Skip to content

Instantly share code, notes, and snippets.

@xadapter
Last active September 8, 2020 21:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save xadapter/74c39b5c0af3324fca7876943a5e92ec to your computer and use it in GitHub Desktop.
Save xadapter/74c39b5c0af3324fca7876943a5e92ec to your computer and use it in GitHub Desktop.
Snippet to clear the default WooCommerce shipping methods/options on the cart and checkout pages. Supports PluginHive Shipping Plugins: https://www.pluginhive.com/product-category/woocommerce-plugin/woocommerce-shipping/
// 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', 99);
// Code to clear default payment option.
add_filter( 'pre_option_woocommerce_default_gateway' . '__return_false', 99 );
@ben72
Copy link

ben72 commented Nov 4, 2016

Does this still work for default gw? Maybe the filter name changed? I can't seem to find it being applied anywhere in WC.
The shipping part works..

@breadadams
Copy link

breadadams commented Oct 26, 2017

Likewise @ben72, the pre_option_woocommerce_default_gateway filter doesn't seem to be working anymore 🤔. Can you recall if you found a solution for this?

@ssoulless
Copy link

I have latest woocommerce version 4.x and this filter is not available anymore.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment