How to Hide WooCommerce Payment Methods by Shipping Zone
Hide Cash on Delivery or another WooCommerce payment gateway for a specific shipping zone while keeping payment options available in other delivery areas.
Last updated:
Reviewed for accuracy by Jesse Nickles
Check the built-in options first
WooCommerce matches a customer's address to the first applicable shipping zone and uses that zone to determine the available shipping methods, as explained in its shipping zone instructions. Payment gateways cannot be assigned directly to a zone through the built-in settings, so check the zone order before adding a custom restriction.
If you only need to restrict Cash on Delivery, first look for Enable for shipping methods under WooCommerce → Settings → Payments → Take offline payments → Cash on Delivery → Manage. As explained in WooCommerce's Cash on Delivery documentation, this limits COD to selected shipping methods or rates. It may be enough when those methods are unique to the intended zones, but it cannot target a shipping zone ID directly.
- In WP Admin, open WooCommerce → Settings → Shipping → Shipping zones. Edit the zone you want to restrict and note its numeric
zone_idfrom the admin URL. Do not confuse it with a shipping-method instance ID. - Check WooCommerce → Settings → Payments and identify the gateway you want to restrict. Use its internal ID rather than the label customers see at checkout.
WooCommerce's built-in offline payment methods use these gateway IDs:
| Payment method | Gateway ID |
|---|---|
| Cash on Delivery | cod |
| Direct Bank Transfer | bacs |
| Check Payments | cheque |
For gateways supplied by payment extensions, including Stripe, PayPal, or WooPayments, check that plugin's documentation or source for the correct ID before editing the snippet.
Hide the gateway for that zone
Back up your site and test changes on staging first. Add this snippet to your active child theme's functions.php, inside the existing PHP code; HoverCraft users can follow its child theme instructions instead of editing the parent theme. Replace 3 with your zone ID, cod with the gateway ID you want to hide, and myshop in both places with a unique site prefix.
function myshop_hide_gateway_by_zone( $gateways ) {
if ( ! function_exists( 'WC' ) || ! WC()->cart || ! class_exists( 'WC_Shipping_Zones' ) ) {
return $gateways;
}
foreach ( WC()->cart->get_shipping_packages() as $package ) {
$zone = WC_Shipping_Zones::get_zone_matching_package( $package );
if ( (int) $zone->get_id() === 3 ) {
unset( $gateways['cod'] );
break;
}
}
return $gateways;
}
add_filter( 'woocommerce_available_payment_gateways', 'myshop_hide_gateway_by_zone', 20 );
The filter uses WooCommerce's shipping zone API to hide the gateway if any shipping package matches the zone. Virtual-only carts may have no shipping package, and stores with split shipments should note that one matching package hides the gateway for the entire checkout.
Test the checkout behavior
- Add a shippable product to the cart and enter an address in the restricted zone. The selected gateway should disappear after checkout updates.
- Change to an address in a different zone. The gateway should return if it is otherwise enabled and eligible.
- Test as a guest and a signed-in customer, and verify that at least one usable payment method remains in the restricted zone.
WooCommerce lists this PHP filter as partially supported in the Checkout Block, so some gateways need additional block-specific handling. Test with your actual gateway, whether your store uses the Checkout Block or classic shortcode checkout.
If the restriction does not work
- Wrong zone: Check the delivery address and
zone_id. - Wrong gateway: Verify the gateway's internal ID. Its label at checkout may not match that ID.
- No change after entering an address: Check the active child theme, PHP errors, caching, and other code that filters available payment gateways. Test on staging before disabling extensions.
- Gateway missing everywhere: Check whether it is enabled and eligible under its normal WooCommerce settings before blaming the new restriction.
Use a restriction plugin instead
WooCommerce's Conditional Shipping and Payments extension can hide gateways through WooCommerce → Settings → Restrictions → Payment Gateways. Add a restriction, choose the gateway under Exclude Gateways, and set conditions such as Shipping Method or shipping destination.
Those conditions are not the same as matching a shipping zone ID. If a shipping method belongs only to the intended zone, a Shipping Method condition may provide the result you need; otherwise, use an exact zone-based rule. Confirm compatibility with your checkout and payment extension before relying on the restriction for live orders.