how to disable payment methods in woocommerce

How to Disable Payment Methods in WooCommerce

Are you looking for various ways to disable payment methods in WooCommerce under specific conditions? We have the perfect guide for you.

WordPress with WooCommerce is the complete solution for your website to run an online store. This is because it allows you to perform all kinds of customizations for the payment methods, gateways, and options. Similarly, you can also disable them for your customers based on particular conditions if needed.

But before we look at how to disable them, let’s have a look at why you may need to disable them first.

Why may you need to Disable WooCommerce Payment Methods?

You may need to disable the payment methods in WooCommerce for many reasons. It all depends on how you manage and run your online store. But the payment methods are disabled in a website usually when the admin wants to test some payment features on their website or when they have to address certain customer conveniences.

Disabling the payment methods is very common when the store has to make transactions internationally with multiple countries too. Most the payment methods are used in every part of the world but some of them may not be available for one or a few countries. These locations may even use some local payment gateways which may be unfamiliar to the rest of the world.

These payment options are irrelevant to your customers from the rest of the world. So if you want to keep your website as clean as possible, disabling these payment options to the customers who don’t use them can also be a big help for you.

Similarly, you can also disable them depending on the cart total, user roles, test purposes on your website, and so on. It all comes down to the need of your website and customers in the end.

Now that you have a brief understanding of why you may need to disable the payment methods, let’s go through the process.

How to Disable Payment Methods in WooCommerce

There are 3 major ways through which you can disable the payment methods in WooCommerce. They are:

  • Default WooCommerce Dashboard
  • Programmatically
  • Using Plugins

We’ll go through each of these options in detail one by one.

But before we begin, we assume that you have properly set up WooCommerce on your WordPress website and have used one of the compatible WooCommerce themes. Please make sure that you have also updated the theme and the related plugin to their latest version. This will reduce the chances of getting any sort of unnecessary issues during the process.

1. Disable Payment Methods from the Default WooCommerce Dashboard

This is the easiest method through which you can disable the payment methods on your WooCommerce store. You can disable certain payment methods or all of them without using any codes or additional plugins.

All you have to do is go to WooCommerce > Settings from your WordPress website and open the Payments tab. Here, you will be able to see all the payment methods installed on your online store along with their description. The status of whether the payment method is enabled or disabled can also be seen in this section.

All the enabled payment methods will be highlighted in purple under the Enabled column. If you want to disable any of the payments in your WooCommerce store from here, just click on the toggle of the Enabled column.

paypal stripe disable payment methods in woocommerce

 

The toggle will be switched and turned into grey. This means that the particular payment method is now disabled for your website and won’t be shown on the checkout page.

For this tutorial, we have disabled the payment methods for Stripe and PayPal. Now if you go to your checkout page, the payment options for Stripe and PayPal won’t be available for your customers.

You can also click on the payment option and uncheck the checkbox for “Enable (Payment Gateway)” to disable them.

Although this is a very quick and easy step to disable the payment methods in WooCommerce, it does have its limitations. When you disable a payment option from the WooCommerce dashboard, it will be completely unavailable for the customers. But if you need to disable the payment methods just under certain conditions, you will have to look for alternatives.

2. Disable Payment Methods in WooCommerce Programmatically

To disable the payment methods in WooCommerce just under specific conditions, the programmatical approach can also be a great option for you. WordPress and WooCommerce do allow you to edit their core files to let you customize your website. But you will need basic programmatical knowledge or hire someone who has them to use this approach.

So before we continue, make sure that you create a child theme for your website either programmatically or by using one of the child theme plugins on your website. Similarly, it’s also worth mentioning to back up your WordPress website as any unnecessary changes to your core files may lead to further issues on your website.

2.1. Deactivate All Payment Methods

Let’s start with the simplest one. You can just add a line of your code in your functions.php file to disable all the payment gateways on your website at once. This can be most helpful if you want to perform some experiments on your website when it is in maintenance mode.

To add the code, just go to Appearance > Theme File Editor from your WordPress dashboard. Here, open the functions.php file and add the following code to the text area.

add_filter( 'woocommerce_cart_needs_payment', '__return_false' );

Don’t forget to click on Update file to save your changes.

When you preview your checkout page, you will be able to see that the payment methods are disabled on the website.

2.2. Hide Payment Options for Specific Country

There’s no guarantee that all the payment methods may work in every part of the world. Some of the payment methods may not work in certain countries. You may need to disable the payment method just for that particular country.

In cases like these, you can use the following code snippet using the slug for the gateway ID.

In the following example, the payment gateway PayPal will be disabled for your customers if the country of the billing address is the US.

add_filter( 'woocommerce_available_payment_gateways', 'quadlayers_payment_gateway_disable_country' );
  
function quadlayers_payment_gateway_disable_country( $available_gateways ) {
    if ( is_admin() ) return $available_gateways;
    if ( isset( $available_gateways['authorize'] ) && WC()->customer->get_billing_country() <> 'US' ) {
        unset( $available_gateways['authorize'] );
    } else {
        if ( isset( $available_gateways['paypal'] ) && WC()->customer->get_billing_country() == 'US' ) {
            unset( $available_gateways['paypal'] );
        }
    }
    return $available_gateways;
}

If you are having difficulties getting the correct gateway ID, just go to the Payments tab on your WooCommerce dashboard like the previously mentioned step. Then, inspect the payment method. You’ll be able to see the ID from this console.

gateway id disable payment methods in woocommerce

After you make all the necessary changes to the code, don’t forget to update the file. Now, if you preview your checkout, the PayPal option will be disabled to you if the billing address is in the US.

2.3. Hide Payment Gateways Based on Cart Total

There may be some cases where you may need to disable the payment methods in WooCommerce depending on the cart total as well. When a certain amount exceeds the cart total, you may need to pay some additional fees for a few payment methods. To avoid that, you can just disable the particular payment gateway and force the customers to make the payment with an alternative payment option.

The following code snippet will allow you to do so.

add_filter( 'woocommerce_available_payment_gateways', 'quadlayers_disable_paypal_above_100' );

function quadlayers_disable_paypal_above_100( $available_gateways ) {
$maximum = 200;
if ( WC()->cart->total > $maximum ) {
unset( $available_gateways['paypal'] );
}
return $available_gateways;
}

In the above demonstration, the payment method for PayPal will be disabled if the cart total exceeds $200.

cart limit disable payment methods in woocommerce

3. Disable Payment Methods using a Plugin

If using codes is too much for you, we have a very good alternative for you as well. Plugins allow you to increase the flexibility of your website and customize them to add the needed features. Therefore, you can also use a plugin to disable payment methods using a plugin.

We will be using the plugin WooCommerce Disable Payment Methods based on cart conditions for this section. It is a free, simple-to-use plugin and as suggested in the name itself, it lets you disable the payment methods according to the subtotal of the cart. So let’s start by installing the plugin.

3.1. Install and Activate the Plugin

To install the plugin, go to Plugins > Add New from your WordPress dashboard and search for the plugin first. After you find the plugin, click on Install Now to start installing the plugin.

The installation of the plugin will take just a few seconds. Activate the plugin as soon as it’s completed.

The plugin also has a premium version which unlocks a wide variety of features. If you want to use it, you’ll need to install the plugin manually.

3.2. Add Cart Conditions

Once the plugin is activated, go to WooCommerce > Conditional Payments Methods from your WordPress dashboard once again. Here, make sure that the checkbox for enabling conditions is checked.

Then, you’ll have to start adding the conditions by clicking on Add condition. You will be redirected to the Add new condition page.

add condition disable payment methods in woocommerce

Here, add the title of your condition first. After that, you can select either to disable or enable the payment method depending on the condition. Since we want to disable the payment method, select the Disable the payment method(s) option.

Now, select the payment methods that you want to disable under the particular condition. You can even select multiple payment methods. Finally, set the conditions for which you want to disable the particular payment methods. For example, we have set a condition to disable PayPal when the cart amount is greater than $200 just like the programmatical approach.

You can further add a new condition or group multiple ones by repeating this process. Lastly, Publish the condition once you make all the necessary changes to it.

When you preview the checkout page, the selected payment method will be disabled when the cart exceeds the condition.

cart limit disable payment methods in woocommerce

That’s it! You just disabled the payment methods using a plugin under specific cart conditions

Conclusion

This is how you can disable the payment methods on your WooCommerce website. They can be very useful for you if you want to hide or disable the payment methods for the customers who can’t use the particular payment options. It also helps you keep your website clean and more functional.

To summarize, we had a look at 3 ways to disable payment methods in this tutorial. They are:

  • Default WooCommerce Dashboard
  • Programmatically
  • Using a plugin

The easiest and quickest approach to disable the payment options is through the WooCommerce dashboard. However, you cannot disable them through the dashboard if you have to add certain conditions for it.

Alternatively, if you want to disable just a number of specific payment gateways under particular conditions, your best option is to use the programmatical approach. There are tons of customizations that you can do with the code snippets regarding it.

But if you are not completely familiar with programming, you can even use a plugin to disable the payment methods under particular conditions.

If you want to further customize your checkout page beside the payment methods, you can also use plugins like WooCommerce Direct Checkout and WooCommerce Checkout Manager.

So can you disable the payment methods on your online store now? Which method is the most approachable for you? Please let us know in the comments.

In the meantime, here are some more articles that might be of use to you: