How Gatemi Conditional Shipping Works

Gatemi Conditional Shipping does one thing: it removes shipping or payment methods from the list WooCommerce is about to show, when a condition you wrote is met. It never adds a method, changes a price or touches an order.

Three rules govern how it does that.

The last-word rule: it filters at priority 100

WooCommerce builds the list of shipping options for each package, then passes it through the woocommerce_package_rates filter, and builds the list of payment methods, then passes it through woocommerce_available_payment_gateways. Other plugins use the same filters — carrier plugins add rates there, some shipping plugins rename them.

This plugin filters both lists at priority 100, after everybody else has had their say. A restriction is therefore the final decision, not a suggestion the next plugin undoes.

Shipping methods, step by step

For every package WooCommerce rates:

  1. The plugin reads the package: its destination country, the lines' subtotal before coupons, the total weight (product weight × quantity), the number of items, and the shipping classes in it.
  2. It takes every active shipping rule, in slot order.
  3. For each rule whose condition matches, it removes the named rates (hide) or everything except them (show only).
  4. What is left is what the shopper sees.

Payment methods, step by step

On the checkout:

  1. The plugin reads the cart and the customer's shipping country.
  2. It applies every active payment rule whose condition matches, the same way.
  3. If no payment method is left, WooCommerce shows its "no available payment methods" message — and the plugin replaces that message with the Tell the shopper sentence of every matching payment rule that has one.

Payment methods are never filtered inside wp-admin, so you can still take a payment by hand on the order screen.

Rules never compete

Each rule is judged on its own, and every rule that matches has its say. Two rules hiding the same method are not a conflict; a hide rule and a show-only rule both apply, one after the other, to what is left. You never have to work out which rule "wins".

Example: courier only for heavy parcels

You offer flat_rate (post) and flat_rate:4 (courier) in your UK zone. Parcels over 20 kg cannot go by post, and light parcels should not be offered the dearer courier.

Rule Restricts Then Methods When
1 Shipping methods show only flat_rate:4 Total weight is at least 20
2 Shipping methods hide flat_rate:4 Total weight is at most 19.99

A 25 kg cart sees only the courier. A 3 kg cart sees post and every other method in the zone except the courier.

The show-only safeguard

A show only rule that would leave nothing is treated as if it had not matched. One typo in a method id — flat-rate:3 instead of flat_rate:3 — would otherwise empty somebody's checkout with no explanation.

Emptying a list on purpose is what hide is for. A hide rule that removes every payment method does leave the checkout with none, and then your Tell the shopper sentence is what the shopper reads.

The strict reading

Gatemi Conditional Shipping understands five conditions: shipping country, subtotal, total weight, number of items and shipping class. The table it writes into can also hold rules made in Gatemi Shipping for WooCommerce, which understands many more — postcode, category, coupon, role, the chosen payment method and others.

A condition this plugin cannot judge is treated as matching, so the restriction stands. A restriction is a protection. A shop that hid cash on delivery outside its county did so because delivering there costs money. Guessing "does not match" would quietly open that door the day the shop stopped running Gatemi Shipping, and the merchant would find out from an order they cannot fulfil. Guessing "matches" costs a method you can see is missing, on a screen that names the rule.

Nested AND/OR groups from Gatemi Shipping are judged the same way: every condition in an "all" group must match, one in an "any" group is enough.

The continuity rule: one table, two plugins

Rules are rows in {prefix}gmship_restrictions, with their conditions stored as the same JSON the full rule builder writes:

{"match":"all","rules":[{"type":"country","operator":"not_in","value":["GB"]}]}

That is the whole point of the plugin's design. When a shop outgrows five one-condition rules, it installs Gatemi Shipping and finds every rule already on that plugin's Restrictions screen — nothing to retype.

While Gatemi Shipping is active, Gatemi Conditional Shipping stands down: it adds no filters and no screen, and says so in a line under its row on the Plugins screen. Gatemi Shipping enforces the same rules from the same table.

Caching of shipping options

WooCommerce caches a cart's shipping options in the shopper's session and works them out again only when the package changes — its contents, its address, or WooCommerce's own shipping settings. Because every condition this plugin reads comes from the package, a change to the cart or the address always brings fresh options. Saving a rule bumps WooCommerce's shipping cache version, the same signal a change to WooCommerce's own shipping settings sends, so every cart works its options out again on its next load. See FAQ and troubleshooting.

Shopping Cart
Scroll to Top