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
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).
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.
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With