How to disable all payment methods in WooCommerce

Disable Payments on WooCommerce

You will have the need to disable all payment gateways on the site, but just disabling them in WooCommerce > Settings > Payments will not work because then the customers will get an error message since there are no payment methods available.

We’re going to be using a different method here. The way to go is to add just a single line code to the functions.php file within your theme folder.

1) Deactivate All Payment Methods

// Do not include this if already open! Code goes in theme functions.php.
add_filter( 'woocommerce_cart_needs_payment', '__return_false' );

The checkout page will now display only a Place Order button.

2) Hide Payment Options for Specific Country

There is no assurance that every payment method will function everywhere in the world. Other of the payment options might not be functional in some nations. It might be necessary to disable the payment option just for that nation.

In these situations, you can use the following code fragment, substituting the gateway ID’s slug.

In the example below, if the billing address is in the US, the PayPal payment gateway will not be available to your clients.

add_filter( 'woocommerce_available_payment_gateways', 'cxc_payment_gateway_disable_country_fun' );

function cxc_payment_gateway_disable_country_fun( $payment_gateways ) {
	if ( is_admin() ) return $payment_gateways;
	if ( isset( $payment_gateways['authorize'] ) && WC()->customer->get_billing_country() <> 'US' ) {
		unset( $payment_gateways['authorize'] );
	} else {
		if ( isset( $payment_gateways['paypal'] ) && WC()->customer->get_billing_country() == 'US' ) {
			unset( $payment_gateways['paypal'] );
	return $payment_gateways;

3) Hide Payment Gateways Based on Cart Total

Depending on the total in the cart, there may be various situations when you need to disable the payment options in WooCommerce. You might have to pay extra fees for a few payment options when your total reaches a particular threshold. Simply disable the specific payment gateway and require consumers to use an alternate payment method to avoid this.

You can do this by using the following line of code.

add_filter( 'woocommerce_available_payment_gateways', 'cxc_disable_paypal_above_call_back' );

function cxc_disable_paypal_above_call_back( $payment_gateways ) {
	$maximum = 120; // set your cart total 
	if ( WC()->cart->total > $maximum ) {
		unset( $payment_gateways['paypal'] );
	return $payment_gateways;

How can I disable GPAY from Woocommerce?

Go to Settings > Payments in Woocommerce, then discover where you enabled Square and click Manage.

How can I disable the cash-on-delivery method in WooCommerce for a certain product?

For example, I’d like to remove the Cash On Delivery (COD) payment option from this product. As a result, I’ll write ‘Disable COD for T-shirt.

How useful was this blog?

Click on a star to rate it!

Average rating 0 / 5. Vote count: 0

No votes so far! Be the first to rate this blog.

  • CodexCoach

    - Web Development Expert

    CodexCoach is a skilled tech educator known for easy-to-follow tutorials in coding, digital design, and software development. With practical tips and interactive examples, CodexCoach helps people learn new tech skills and advance their careers.

Leave a comment

Your email address will not be published. Required fields are marked *