WooCommerce Conditional Payment Methods: Hide Gateways by Rule
Set up WooCommerce conditional payment methods that hide gateways by product, cart total, country, shipping or role, then test them on both checkouts.

Photo: Pixabay
On this page 8 sections
- The Two Conditions Built Into Cash on Delivery
- How WooCommerce Conditional Payment Methods Work Under the Hood
- Five Conditions and the Mistake Each One Invites
- A Worked Rule Set for a Roaster Selling Retail and Wholesale
- What Hiding a Gateway Won't Do
- Put Net Terms and ACH Behind a Human Approval
- Payment Rules Don't Replace Underwriting
- Test Both Checkouts Before Shoppers Find the Gaps
Key takeaways
- Before adding any plugin, limit cash on delivery to local delivery or pickup. WooCommerce marks unpaid COD orders "Processing," the same status a paid order gets.
- Checkout rules only control what shoppers see. They don't apply when staff key orders in the admin, and they don't stop card-testing scripts.
- Write a rule table and test the smallest and largest order for each customer type. Any combination that leaves zero payment methods needs a fallback.
- Using rules to send unapproved products through a second gateway can be treated as transaction laundering, which is a MATCH reason code.
WooCommerce conditional payment methods are rules that show or hide a payment gateway at checkout based on what's in the cart, the order total, the destination, the shipping method or the customer's account. WooCommerce core supports only two of these conditions, and both sit on the built-in cash on delivery gateway. Every other rule, whether a plugin or a snippet sets it, works by trimming one list: the gateways WooCommerce considers available to this shopper for this cart.
The Two Conditions Built Into Cash on Delivery
WooCommerce's Cash on Delivery documentation lists two conditional settings on the COD gateway. "Enable for shipping methods" chooses which shipping methods and rates offer COD. "Accept for virtual orders" is a checkbox that allows COD on virtual products.
Set the first one before anything else, because of how WooCommerce files a COD order. The same documentation says WooCommerce marks COD orders "Processing" until payment is collected. That is the status a paid order gets, so an unpaid COD order lands in your fulfillment queue looking ready to ship. If COD stays open on carrier shipping, a packer can send a box across the country with no one at the other end to collect the money. Limit COD to local delivery or pickup, and leave the virtual-orders box unchecked unless someone really collects payment in person.
How WooCommerce Conditional Payment Methods Work Under the Hood
Before the checkout page shows payment options, WooCommerce passes its enabled gateways through a filter named woocommerce_available_payment_gateways. Code hooked to that filter removes a gateway when a condition is true, and the shopper sees what remains. Role-based snippets from Business Bloomer and Misha Rudrastyh are built on this hook, and most rules plugins are a settings screen on top of it.
This is the part store owners tend to misread. WooCommerce's code reference for WC_Payment_Gateways warns that logic hooked to the available-gateways filter may rely on a customer session, and that it can cause fatal errors where no session exists. In practice the filter belongs to the shopper's checkout. When staff key a card on an order in the admin, as described in taking phone orders in WooCommerce, your checkout rules aren't the control. Nor do they stop scripts that talk to your gateway directly.
You can build rules with a plugin or with code:
| Factor | Rules Plugin | Code Snippet |
|---|---|---|
| Setup | Settings screen, no code | A developer writes and tests it |
| Adding a rule | Minutes, from the admin | More code to maintain |
| Who can see the rules | Anyone with admin access | Only someone who reads the code |
| Block checkout support | Check the plugin's compatibility notes | Depends on how it's written |
| Ongoing cost | License fee, if any | Developer time after updates |
A maintained plugin suits most stores, because whoever edits shipping zones next year can see the payment rules that depend on them. A snippet is fine for one or two fixed rules, kept in a child theme or snippet manager so a theme update doesn't erase it.
Five Conditions and the Mistake Each One Invites
Product, category or product type. Use these when the item itself changes the risk. Subscriptions need a gateway that saves cards for renewals. Made-to-order goods shouldn't go into production on an unpaid offline order, and gift cards attract fraud, so keep them on card payment. The mistake is a mixed cart. Decide on strictest-wins: a gateway stays available only if every item in the cart allows it.
Cart total. Minimums and maximums keep a method in a sensible range, such as capping COD at what a driver should carry. Find out whether your plugin reads the subtotal before or after coupons, since a coupon applied at checkout can push a cart across your threshold.
Country. Tie delivery-based methods such as COD to the shipping country. Tie payer-based methods such as a local bank transfer to the billing country. Cross-border pricing is a separate decision, covered in showing local prices without losing margin, and MannyPay offers international payment processing with multi-currency acceptance and settlement review.
Shipping method. Core handles this for COD only. Plugins extend it to other gateways, such as a "pay at pickup" option that appears only when the customer picks local pickup.
User role. Role rules show a method only to logged-in accounts with a given role, such as wholesale buyers. Guests aren't logged in and have no role, so they never see a role-restricted method.
If you haven't settled which methods to offer in the first place, start with which payment methods your online store should accept.
A Worked Rule Set for a Roaster Selling Retail and Wholesale
Take a hypothetical coffee roaster. The store and every threshold here are illustrative, not recommendations. It ships retail bags nationwide by carrier, offers local delivery in its metro area, sells subscriptions and gift cards, and supplies cafés on wholesale accounts. It runs four gateways: a card gateway that saves cards for renewals and supports 3D Secure, COD, an ACH gateway, and the built-in check gateway renamed "Invoice: Net 30."
| Gateway | Who Sees It | Hidden When |
|---|---|---|
| Card | Everyone | Never |
| COD | Local delivery customers | Cart has a gift card or subscription, or subtotal is over $300 |
| ACH | Wholesale role only | Customer is a guest or retail account |
| Invoice: Net 30 | Wholesale role only | Order is under a $150 minimum |
Run three carts through it. A guest buys two bags and a gift card for local delivery. COD would normally appear, but strictest-wins means the gift card removes it, so the guest sees card only. A retail customer orders a subscription and a bag by carrier. COD fails both the shipping test and the subscription test, which leaves the card gateway, the one that can save the card for renewals. A logged-in café ordering $400 for carrier delivery sees card, ACH and Invoice.
Now change one rule and watch what breaks. Say the roaster hides the card gateway from wholesale accounts to push cafés toward ACH, and also puts the $150 minimum on ACH. A café placing a $90 rush order by carrier fails card (role), COD (shipping), ACH (minimum) and Invoice (minimum). It sees no payment method at all. On the block checkout, that shows up as WooCommerce's generic "no payment methods available" notice, which looks like a broken store.
So write the table before you touch any settings. Give every gateway a one-line answer to "who sees it," then check each customer type against the smallest and largest order it might place. Any combination that ends at zero needs a fallback, usually the card gateway.
What Hiding a Gateway Won't Do
Rules do cut exposure on risky-looking orders, such as large orders of easily resold goods or mismatched billing and shipping countries. Hide offline methods there so you aren't holding stock for a buyer who may never pay, and route those orders to card payment with 3D Secure authentication, which adds a verification step with the card issuer. Whether a 3D Secure order shifts fraud liability depends on network rules and your processor's terms, so read how liability shift works for online stores before you turn it on for every order.
Hiding a gateway does not stop card testing. The available-gateways list only controls what the checkout page displays, and card-testing scripts often skip that page. Velocity limits, CAPTCHA and other gateway-side controls do that work. See stopping card testing on your WooCommerce checkout.
Put Net Terms and ACH Behind a Human Approval
Wholesale buyers often prefer ACH or net-terms invoices on large orders, and both can cost less to accept than cards. But net terms are credit you extend, so a role rule is only as good as the approval behind it.
- Create a wholesale role with a wholesale plugin or a developer.
- Assign it by hand after reviewing a credit application and trade references, never automatically at registration.
- For net terms, rename the check gateway or use an invoicing plugin. For bank payments, use a gateway that supports ACH or eCheck.
- Show both methods only to the wholesale role, with an order minimum if you want small orders to go through normal checkout.
- Track credit limits outside the payment rules, because no rule checks open invoices before it accepts an order.
If you plan to reward early payment, pricing 2/10 net 30 against card fees walks through the math. If you'd rather pass card costs to the buyer, read what's legal when adding a card fee in WooCommerce first. Card surcharges are governed by card network rules and by state law, so confirm your plan with a qualified professional.
Payment Rules Don't Replace Underwriting
Use rules to shape checkout and manage risk, never to hide activity from your processor. Sending products your main processor didn't approve to a second gateway crosses that line. So does running restricted items through an account approved for a different kind of business. Both can be treated as transaction laundering.
The consequence outlasts one account. Visa and Mastercard maintain terminated merchant files, Mastercard's MATCH and Visa's VMSS, and Stripe's summary of the MATCH criteria lists laundering as its own reason code: presenting transactions that weren't valid sales between the merchant and a real cardholder. Acquirers check these files when you apply. If your processor won't support part of your catalog, get an account approved for those products, such as a high-risk merchant account, and disclose everything you sell.
Test Both Checkouts Before Shoppers Find the Gaps
WooCommerce's 8.3.0 release post (November 16, 2023) made the Cart, Checkout and Order Confirmation blocks the default for new installations. Older stores that updated kept their existing checkout. Depending on when your store was built, you could be on either, and a rule that works on one isn't proof it works on the other.
The block checkout also fails in its own way. WooCommerce's guide to customizing the cart and checkout pages says a gateway that isn't compatible with the block checkout may not appear, and that when only incompatible gateways are active, customers see "There are no payment methods available." The Checkout block's settings include a one-click switch back to the classic checkout.
Set up a staging site with every gateway in sandbox mode and run each row of your rule table on the checkout you use. Then:
- Change the country and apply a coupon partway through to confirm the payment list refreshes.
- Try express payment buttons on product and cart pages, which can bypass checkout-page rules. If they misbehave, see these fixes for Apple Pay not showing on WooCommerce.
- Create an order in the admin and send yourself the payment link to test the pay-for-order page.
- Confirm the cart and checkout pages are excluded from page caching.
After launch, watch abandoned checkouts by country and shipping method. A spike in one segment usually means a rule is stricter than you meant.
Rules can only filter the gateways you already have, so the gateway itself is the bigger decision. Check yours against our checklist for choosing a WooCommerce payment gateway. MannyPay supports WooCommerce payment integration and gateways including Authorize.net and NMI. Request a free quote with your rule table in hand, and a MannyPay specialist will respond within one business day.
Sources
- Cash on Delivery Documentation, WooCommerce
- WC_Payment_Gateways, WooCommerce Code Reference
- WooCommerce: Disable Payment Gateway for Specific User Role, Business Bloomer
- How to Configure Payment Gateways by User Roles, Misha Rudrastyh
- WooCommerce 8.3.0 Released, WooCommerce Developer Blog
- Customizing the Cart and Checkout Pages, WooCommerce
- Terminated Merchant Files (MATCH and VMSS), Stripe Documentation
This article is for general educational purposes and is not legal, tax or financial advice. Card network rules and state laws change; confirm current requirements for your business.


