Skip to content
Advertisement

Remove WooCommerce Payment Gateways for defined groups of product categories

I’ve manged to get this code to work for removing ONE payment gateway based on one or more product categories.

What I need help with is removing multiple payment gateways as well. In other words; it should remove one or more payment gateways based on one or more product categories.

This is what I got, which might be outdated?

JavaScript

Advertisement

Answer

Yes it’s possible to disable payment gateways for groups of multiple product categories.

1) In the separated function below we define our groups of product categories and payment gateways. The product categories can be either term(s) id(s), slug(s) or name(s). So in this function we define our settings, to be used:

JavaScript

2) Now the hooked function that will remove, in checkout page, the payment gateways based on the cart items product categories, loading our settings function:

JavaScript

Code goes in functions.php file of your active child theme (or active theme). Tested and works.

User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement