Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to disable default shipping and payment options on checkout with WooCommerce?

I am looking for a way to disable the default payment option and shipping option on the "view cart" and/or "checkout" pages on WooCommerce.

Everything I have tried did not work. JS is failing since this section is keeping refreshed. and PHP fails since it refreshes unselected on every change in the cart.

Any idea of how to do that?

Thanks

like image 620
Shir Gans Avatar asked Sep 03 '15 13:09

Shir Gans


People also ask

How do I prevent WooCommerce from selecting default payment method on checkout page?

However, the default should be the 'top' option, so if you'd like to change that default selection, you can re-arrange the payment methods on the WooCommerce > Settings > Payments page and just put them in the order you want them to be shown on the Checkout page (top-down, default at the top).

How do I change the default shipping method in WooCommerce?

Click Settings in the expanded WooCommerce menu. Click the Shipping tab. Edit the Shipping Zone by clicking the Edit link or the zone name. Reorder the Shipping Methods by dragging and dropping the shipping method.

How do I turn off WooCommerce Payments?

To remove the check payment method, click on the cheque link. Here you'll see the checkbox marked as checked. This checkbox will determine whether to enable/disable check payment option.


1 Answers

This should do the trick:

add_filter( 'pre_option_woocommerce_default_gateway' . '__return_false', 99 );
add_filter( 'woocommerce_shipping_chosen_method', '__return_false', 99);

This does only remove the default selection. If the selection is stored in your session it will be applied as normal. Keep that in mind when testing.

Edit: Unfortunately, since WooCommerce 4+ this does not work anymore.

like image 143
Pelmered Avatar answered Sep 28 '22 11:09

Pelmered