In this tutorial, we will show you how to disable WooCommerce payment gateways by shipping method.
In WooCommerce, shipping methods are available depending on the selected shipping zone.
For example, the “Local” shipping zone may have the “Local pickup” and “Free shipping” shipping methods enabled.
This is great for your city or region.
But if you ship your products to other cities or states in a large country like the United States, you can create a shipping zone called “Domestic zone” and enable other shipping methods like “Flat rate” for that zone.
The same can apply if you ship to other countries.
The thing here is that you may need to disable WooCommerce payment gateways by shipping method.
For example, you may want to disable the “Cash on delivery” payment gateway for the “Flat” rate shipping method.
Or you may need to disable the “Direct Bank transfer” payment method for the “Flat rate” shipping method.
And that’s what you’ll learn in this tutorial: how to disable payment methods for specific shipping methods, based on the shipping zones.
Just follow these steps:
1- Set up your WooCommerce shipping zones and shipping methods
Make sure you have correctly set up your shipping zones in WooCommerce.
For example, we have created three shipping zones:
- Local zone. This is for California, and has the “Local pickup” and the “Free shipping” shipping methods enabled.
- US domestic zone. This is for the rest of the United States and has the “Flat rate” shipping method enabled.
- Europe and South America. This is for Europe and South America and has the Flat rate shipping method enabled.
Once you have set up your shipping zones, you can proceed to disable payment gateways based on the shipping method.
2- Install the “Conditional Payment Gateways” plugin
This plugin allows you to create conditions for your WooCommerce payment gateways.
You can disable or enable payment gateways based on country, city, state, product, category, shipping method, and a lot more parameters.
You can download the plugin here: Download WooCommerce Conditional Payment Gateways Plugin - or - Read more
3- Create a new condition for your payment methods
To create a new condition for your payment gateways, go to WooCommerce > Conditional Payment Methods.
Now, you need to click on the Add condition button in order to create the condition to disable a payment gateway for specific shipping methods.
4- Disable WooCommerce payment gateways by shipping method
In this example, we will disable the Cash on delivery payment gateway for all the shipping zones that have the Flat rate shipping method enabled.
We need to select the following values:
- Add new condition – Enter the condition title. We will call it: “No cash on delivery for Domestic zone, Europe and South America”.
- What happens when the conditions are met: Disable the payment method(s)
- Select the payment methods: You need to select the payment methods you want to disable here.
- Conditions: We will create two conditions in this case, because we want this conditional restriction to apply both when users need their products shipped to the US domestic zone or when they want their products shipped to the Europe and South America zone. However, you could add one condition only.
- Condition 1: Shipping method = Select the zone here
- Optional – If you want to add another shipping zone for this restriction, click on the Add “Or” group button.
- Optional – Condition 2: Shipping method = Select the zone here
- Once you have configured the restriction, click on Publish
Once you have set up the conditional restriction for your payment gateways, you need to make sure the Enable conditions checkbox is enabled at WooCommerce > Conditional Payment Methods.
5- Check the conditional payment gateway restrictions
Now that we have disabled the cash on delivery payment gateway for the Flat rate shipping method, you can see that it’s available only when the flat rate shipping method is not available.
However, it’s not available when the Flat rate shipping method is selected.
You can enable or disable WooCommerce payment gateways for specific shipping methods with the conditional restrictions of the Conditional Payment Gateways plugin.
You can download the plugin here: Download WooCommerce Conditional Payment Gateways Plugin - or - Read more