How to Restrict WooCommerce Payment Methods Based on Product Types

As a WooCommerce website owner, you know that each payment method has its own advantages and disadvantages. Some have lower transaction fees, others work better to reduce disputes and fraud.

That’s why you may sometimes want to hide certain payment gateways and switch to other payment methods to increase conversion and profits. Let’s look at how to restrict WooCommerce payment methods based on product types, the benefits of this practice, and how to implement it. We’ll also cover the 3 best plugins to disable payment methods based on product types.

When you should hide payment methods by product type

Let’s say you have a WooCommerce shop with premium products – subscription items with high prices and top-notch customer support. You prefer customers to pay by bank transfer instead of credit card.

This is one of the most common practices widely used among WooCommerce shop owners as it increases conversion and lowers transaction fees.

Some payment platforms charge high fees for international transactions. Direct bank transfer is useful for high value orders as it lowers costs and increases profits.

Some payment methods make it easier for customers to dispute an order. By disabling payment methods for certain products, you can eliminate the risk of disputes that cost more than the original order value. You can also set up other payment methods such as checks or credit cards for expensive products to prevent counterfeit orders and fraud.

How to manually restrict WooCommerce payment methods for specific categories

If you’re technically inclined, you can restrict WooCommerce payment methods using a custom hook function in the woocommerce_available_payment_gateways filter hook. You need to add a code snippet to your PHP file.

Once you have properly secured your website, follow this guide to disable WooCommerce payment gateways based on cart items (product type).

In your WordPress dashboard, go to Appearance > Theme Editor. Find the theme’s functions.php file and paste the following code:

phpadd_filter('woocommerce_available_payment_gateways', 'conditional_payment_gateways', 10, 1);

function conditional_payment_gateways( $available_gateways ) {
    // Not in the backend (Admin)
    if( is_admin() )
        return $available_gateways;

    $prod_variable = $prod_simple = $prod_subscription = false;

    foreach (WC()->cart->get_cart() as $cart_item_key => $cart_item ) {
        // Retrieve the WC_Product object
        $product = wc_get_product($cart_item['product_id']);

        // Retrieve the product types in the shopping basket
        if($product->is_type('simple')) $prod_simple = true;
        if($product->is_type('variable')) $prod_variable = true;
        if($product->is_type('subscription')) $prod_subscription = true;
    }

    // Remove cash on delivery for simple products
    if($prod_simple)
        unset($available_gateways['cod']);

    // Remove PayPal for variable products
    if($prod_variable)
        unset($available_gateways['paypal']);

    // Remove bank transfer for subscription products
    if($prod_subscription)
        unset($available_gateways['bacs']);

    return $available_gateways;
}

Top 3 plugins to restrict WooCommerce payment methods

For those who prefer not to work with code, WordPress plugins can help. Here are the top 3 options.

1. WooCommerce Conditional Payment Gateways

This plugin offers flexible restrictions for WooCommerce payment methods. It supports hiding payment methods by product type, and lets you set up restrictions for product height, length, weight, colors, sizes, brands, custom taxonomies and product attributes.

It allows you to enable or disable payment gateways based on shopping basket conditions. The plugin has simple yet strong conditional logic for creating advanced visibility conditions.

Price $29 per year for one website with a 7-day free trial.

2. Payment gateways per product/category/day for WooCommerce

This free plugin specializes in showing and hiding certain payment gateways for certain products. It gives you control over which payments display based on product tags and categories.

This plugin works well for hiding products or categories that have low profit margins or certain payment gateways with high transaction fees.

Price Free. The Pro version starts at $19.99 for a single website with a 30-day return guarantee.

3. Restrict WooCommerce payment methods

WooCommerce Restrict Payment Methods allows you to restrict payment methods based on specific products or categories. You can also hide payment methods depending on custom user roles, cart item quantities, total prices, shipping methods or countries.

Price $21

Conclusion

Hiding payment methods based on product types improves conversion, lowers transaction fees and reduces the risk of paying for disputes.

We’ve shown you how to manually restrict WooCommerce payment methods for specific products and introduced 3 plugins to help simplify this task.