Conditional Payment Methods by Product & Country

  • June 22, 2026
  • Deepak Gupta
  • 5 min read

This time, I will show you two ways to enable or disable payment methods in your WooCommerce store based on two conditions:

Condition 1: A specific product in the cart (including subscription products).

Condition 2: A customer’s billing or shipping country.

The goal is to combine both conditions. For example, what if you want to allow a payment gateway only when selling a subscription product to customers from a specific country?

This setup is particularly useful when using a WooCommerce Plugin Subscription solution and managing different payment requirements for international customers.

Method 1. Setting Up Payment Conditions Using a Plugin

If you prefer not to write custom code, a conditional payments plugin can help you configure payment gateways quickly.

Many WooCommerce stores use plugins that allow payment methods to be enabled or disabled based on:

  • Products in cart
  • Product categories
  • Customer location
  • Cart totals
  • Subscription status

After installing a conditional payments plugin:

  1. Navigate to WooCommerce → Settings.
  2. Open the Payment Conditions section.
  3. Click Add New Condition.
  4. Select the desired payment gateway.
  5. Configure your rules.

Example Configuration

Let’s say we want to disable Cash on Delivery when:

  • Product ID = 25 is in the cart.
  • Customer country = Australia (AU).

Choose:

Action: Disable Payment Method

Gateway: Cash on Delivery

Then add two conditions:

  • Product ID equals 25
  • Billing Country equals Australia

Save the rule and test the checkout process.

This method is particularly useful for stores running a WooCommerce Plugin Subscription setup where payment gateways may differ based on customer location.

Example is in the screenshot below:

WooCommerce > Settings > Conditions > Payment conditions

First of all, in the “Action” select dropdown field, let’s choose “Disable payment methods”, and in another field that will appear, we need to select one or multiple payment methods:

After that, let’s scroll down to the “Conditions” section and add two of them:

As you can see from the screenshot, you can easily select multiple countries; there are no limits to that, however, you can only select one product.

Method 2. Programmatically

If you prefer a custom solution without relying on additional plugins, you can use the following code snippet.

The example below disables Cash on Delivery when Product ID 25 is purchased from Australia.

/**
 * Payment Methods by Product & Country
 */

add_filter( 'woocommerce_available_payment_gateways', function( $available_gateways ) {

	if ( is_admin() ) {
		return $available_gateways;
	}

	$country = WC()->customer->get_billing_country();

	if ( 'AU' !== $country ) {
		return $available_gateways;
	}

	foreach ( WC()->cart->get_cart_contents() as $cart_item ) {

		if ( 25 == $cart_item['product_id'] ) {

			if ( isset( $available_gateways['cod'] ) ) {
				unset( $available_gateways['cod'] );
			}

			break;
		}
	}

	return $available_gateways;

} );

Understanding the Code

Check the Customer Country

$country = WC()->customer->get_billing_country();

You can also use:

$country = WC()->customer->get_shipping_country();

if your business logic depends on shipping destination instead.

Check Products in the Cart

foreach ( WC()->cart->get_cart_contents() as $cart_item )

This loops through all cart items and allows you to target specific products.

Disable a Payment Gateway

unset( $available_gateways['cod'] );

This removes the Cash on Delivery option from checkout.

Working with Subscription Products

When using a WooCommerce Plugin Subscription, you may want to restrict payment gateways that do not support recurring billing.

For example:

  • Allow Stripe for subscription products.
  • Disable Cash on Delivery.
  • Restrict Bank Transfer for recurring payments.

This helps ensure subscription renewals process correctly without payment interruptions.

Headless WooCommerce Considerations

If your store uses a Headless WordPress WooCommerce architecture with React, Next.js, or another frontend framework, payment conditions should still be handled on the WooCommerce backend.

Even in a headless setup, WooCommerce remains responsible for:

  • Cart validation
  • Payment gateways
  • Order processing
  • Subscription management

The same conditional logic can be applied through WooCommerce hooks and APIs.

Testing Your Payment Rules

Before deploying to production:

  • Test with multiple countries.
  • Test subscription and non-subscription products.
  • Verify gateway availability.
  • Confirm checkout completion.
  • Test renewal payments if using subscriptions.

This ensures customers always see the correct payment options.

Final Thoughts

Conditional payment gateways can significantly improve the checkout experience by showing customers only the payment methods that are relevant to their location and products.

Whether you use a plugin-based solution or a custom code approach, WooCommerce provides the flexibility needed to create advanced payment workflows for both standard and subscription-based stores.

If you’re building advanced checkout functionality, implementing a Headless WordPress WooCommerce store, customizing a WooCommerce Plugin Subscription, or need expert assistance with complex WooCommerce development, consider hiring a professional.

Need Help with WooCommerce Customization?

Looking for a reliable Hire WooCommerce Developer service? Whether you need custom checkout rules, subscription management, payment gateway integrations, Headless WordPress WooCommerce development, or full MERN Stack Development Services, an experienced WooCommerce expert can help you build scalable and high-performing eCommerce solutions tailored to your business needs.

Please leave a comment below if you have any questions.

Leave a Reply

Your email address will not be published. Required fields are marked *