how to disable payment methods in woocommerce

How to Disable Payment Methods in WooCommerce

Are you looking for various ways to remove payment methods in your store? We’ve got you covered. In this guide, we’ll show you different ways to disable payment methods in WooCommerce both with and without plugins.

WooCommerce is the complete solution for your website to run an online store 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.

Before we look at how to remove some payment methods, let’s have a look at why you may need to disable them first.

Why may you need to deactivate WooCommerce payment methods?

There are many reasons why you may need to deactivate certain payment methods. It all depends on how you manage and run your online store. Usually, payment methods are disabled 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 in some 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 customers from other parts of the world so it’s better to hide those options from them to keep your website as clean as possible. In that case, disabling these payment options to the customers who don’t use them is the way to go.

Similarly, you can also remove 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.

Before you begin, make sure that you have properly set up WooCommerce on your WordPress website and have used one of the compatible WooCommerce themes. Also, ensure 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 to deactivate payment methods on your WooCommerce store. You can either disable certain payment methods or all of them without using any code 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 way to disable the payment methods in WooCommerce, it does have its limitations. When you deactivate a payment option from the WooCommerce dashboard, it will be completely unavailable for all the customers. So if you want to hide 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 allow you to edit their core files and customize your website.

Note that for this method you will need basic programming knowledge. Before you continue, make sure that you create a child theme for your website either programmatically or by using one of the child theme plugins. Similarly, it’s also worth mentioning to back up your WordPress site 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 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

All in all, this is how you can disable the payment methods on your WooCommerce website. These options can be very useful if you want to hide or disable the payment methods for certain customers.

To summarize, in this tutorial we’ve had a look at 3 ways to deactivate payment methods:

  • Default WooCommerce dashboard
  • Programmatically
  • Using a plugin

The easiest and quickest approach to hide the payment options is through the WooCommerce dashboard. However, it has some limitations and it may not be very useful if you want to add certain conditions.

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 code snippets.

If you aren’t familiar with programming or don’t feel comfortable writing code, you can use a plugin to disable the payment methods under particular conditions.

If you want to further customize your checkout page, have a look at other plugins like WooCommerce Direct Checkout and WooCommerce Checkout Manager. They will help you improve your conversions and take your store to the next level.

Which method did you use to disable the payment methods on your online store? Please let us know in the comments below.