How to hide payment methods by product or category in WooCommerce

By default WooCommerce will show all the active payment methods on your final purchase page but that's not always the case

Imagine, for example, that in some product you do not want to be able to use the bank transfer, or Paypal, or cash on delivery .

Situations can be very varied, from a immediate delivery product where the bank transfer or simply virtual products where it does not make any logic to show the payment on delivery or cash on delivery, right?


Well, WooCommerce allows us to decide many things in your settings or in the details of the products, but this does not. Let's take the reins .

Hide payment methods by product with code (FREE)

If you know what products you want hide some payment gateways nothing better than use a bit of code. Just add it to the file functions . php of your active theme or to your customizations plugin or mu-plugin .

In the previous example you should only take into account the variables to be modified. On the one hand there is the array $ prodids which is where you put the list of IDs of your products for which you want to hide payment gateways, in the example IDs 15 and 30. [19659003] To know the ID of a product you just have to go through the product administration page, there you have it clearly, when you hover over any product.

Another parameter to take into account is the payment gateway (s) to be hidden, in the example Paypal (paypal) and cash on delivery (cod). If you want to add or remove payment gateways to hide just follow the example, can also hide other gateways like bank transfer (bacs), Stripe (stripe) or others, depends on your goal.

To know the ID of the payment gateways just stop by the administration of your store in WooCommerce -> Settings -> Finish [19659010] purchase and there you have them.

Hide payment methods by category with code (FREE)

You can also decide which payment gateways to hide , not by product but by complete category . You can do it with this other code.

Hide payment methods by category with plugins (FREE)

As we have seen, another way to hide payment methods is to do so by product category , and for this there are some free plugins that offer this possibility for free.

WooCommerce Product Payments

The free version of this plugin serves for that exactly, for choose for what categories you will hide payment methods ] But your approach is different, in fact what you do is choose the payment method, only one, available for each category of product.

In your settings page you will find the list of your product categories, select one or several and choose your default payment method, the rest will be hidden on the final purchase page.

As you can see it is somewhat limited, since you can not select several payment methods by category

Booster for WooCommerce

In its free version you can hide each payment method by product category you just have to start typing category names in each payment method to hide it. [19659003] For this use it is quite more complete than the previous one since its approach is just the opposite, and the correct one. But, as you see, the options to hide gateways per product are disabled, only available in the plus version .

Hide methods of payment by product with plugins (DE PAGO)

Interestingly, all plugins that offer hide payment methods do not offer the option to do it for free, only by category so if you want this option with plugins, you have to go through box

Some plugins that offer that option in their paid version are these:

Booster Plus for WooCommerce ($ 19.99)

Now yes, in its paid version the fields are already active to hide payment gateways per product.

WooCommerce Payment GateWay per product premium (19.95 € / year)

This plugin is the version of payment of the free WooCommerce Products Payments and for this modest amount ad annual you can already specify which payment gateways will be available in each product, and in the right way, using a new widget in the product editor .

If you do not select any, all the gateways will be displayed, and if you select any one will be shown the ones chosen.

WooCommerce Conditional Shipping and Payments (79 $)

This plugin from the creators of WooCommerce offers, among its multiple configurations, the possibility of choosing which payment gateways will be displayed by product, category, country or shipping method. Very complete, yes, fully configurable as you can see in the following screenshot.

As you can see, something that I consider so Basic is not included in WooCommerce by default, but fortunately we have options to spare, paid and free.

Loading …

That may also help you:

Open the WordPress "style" store again

You can now order your favorite accessories with the WordPress brand in the store WordPress Swag . How many times have you wanted to apologize for your favorite CMS and you could not or have had to find your life in local personalization stores? Well, nothing, it's over, we already have the new official store ready .

In WordPress Swag there is a bit of everything, and I suppose the catalog will grow. Of course, the store is mounted with WordPress, plus the cart system of PHPpurchase . At the moment you can order your classic shirt with the WordPress logo or the one indicated for "coders" with the text "Code is poetry", but there are also other accessories like ] USB WordPress in which to carry your local installation the iPhone case or the mythical WordPress mug and the fantastic Moleskine WordPress edition (which I have already ordered).

For my taste, it only has one failure, and that is that you can not pay through Paypal, a delay. The prices are not bad, so they'll take you out of a hurry this Christmas, do not you think?