Let’s take a look at how to disable a payment gateway by product category in WooCommerce. We will automatically detect if a specific product category is in the cart and disable the selected payment gateway (PayPal, Stripe, Direct Bank Transfer, Cash on delivery, Cash on pickup, etc.).
For example, you may have a category containing only high-priced products and want your customers to pay with bank transfers instead of using a credit card. In this case, we can disable the credit card payment gateway for the high-priced product category. Of course, this is just an example of the many situations in which you may need to disable a payment method for an entire product category.
Something important to mention is that we’re not using any PHP snippets. You don’t need to know how to code. Instead, we’ll use the WooCommerce Conditional Payment Gateways plugin, so you need to install and activate it on your WordPress site.
You can download the plugin here: Download WooCommerce Conditional Payment Gateways Plugin - or - Read more
After installing and activating the plugin, you need to follow the steps below in order to disable payment gateways for specific product categories.
Create a new condition for your WooCommerce payment gateways
This plugin helps you create conditions in which your payment methods will be disabled.
Go to WooCommerce > Conditional Payment Methods and click on the Add condition button in order to create a new condition.
Disable payment gateway by product category in WooCommerce
To disable a payment gateway by product category in WooCommerce (Stripe, for example), you need to set these values in the new condition you’re adding:
- Add new condition: Enter the condition title
- What happens when the conditions are met: Disable the payment method(s)
- Select the payment methods: Credit Cart (Stripe), for example.
- Condition 1: Taxonomy: Product categories = Dresses (This is an example, you select the category you want)
- Click on Publish.
See the result!
After disabling the payment gateway for a specific product category, the plugin will detect if any product from the restricted category is in the cart. If the product is in the cart, the plugin will disable the selected payment gateway. In this case, you can see that we can’t use the Stripe payment method, because we have added products from the Dresses category to the cart.
The WooCommerce Conditional Payment Gateways plugin allows you to disable payment gateways using any product taxonomy like category, tag, attribute, etc.
You can find more tutorials on the WooCommerce Conditional Payment Gateways here.
You can download the plugin here: Download WooCommerce Conditional Payment Gateways Plugin - or - Read more