WooCommerce: show or hide a shipping method by product category
Some products can’t go with every shipping option: glass that a bike courier shouldn’t carry, frozen food that needs the cold van, cakes that need two days’ notice. Some categories need a limit per order: at most 2 sale items, at least 6 bottles. This page shows what WooCommerce does on its own, the free and paid ways around it, and how the ReachZone Delivery Slots add-on sets both up.
The short answer
WooCommerce has no setting to hide a shipping method for a product category, and none for a minimum or maximum number of items from a category. The add-on adds both in one place, WooCommerce, Delivery slots, section “Category rules”: for each shipping method choose “Not for these categories” or “Only for these categories”, and add category limits that stop checkout. It is included in the ReachZone Pro, Business and Agency plans, and it needs no delivery slots.
What WooCommerce does on its own
WooCommerce has shipping classes. You give products a class, and a method such as Flat Rate can charge a different amount for each class. WooCommerce’s own help says classes are used to group products and cannot be used to directly offer shipping rates to customers. Classes change a price, not which methods the shopper sees, and they are not product categories.
Ways around it
- Hide a method with code. A common snippet uses the
woocommerce_package_ratesfilter. It checks each cart item’s categories and removes one named shipping rate when it finds a match. It works, but it names one method by its id (such aslocal_pickup:3), so you must change the code when your shipping setup changes, and you must keep it working across updates. - Limit items per category with code or an extension. A snippet on the
woocommerce_check_cart_itemshook can count a category’s items and block checkout. WooCommerce’s own Min/Max Quantities extension has minimum and maximum rules for categories, and works with the cart and checkout blocks. It sets limits only; it does not hide shipping methods.
If you need only one of the two and are happy with a plugin for it, those are fine. The add-on is for shops that want both without code.
An example: a deli
A made-up deli ships with a courier at $6 and a cold van at $12. The courier can’t take anything in “Frozen”. The van is offered only when every item in the cart is “Frozen” or “Chilled”. Wine is sold in cases, so the deli wants at least 6 bottles per order when the cart has any wine, and at most 2 sale items.
| Shipping method | Rule | Price |
|---|---|---|
| Courier | Not for “Frozen” | $6 |
| Cold van | Only for “Frozen” and “Chilled” | $12 |
A cart with only crackers sees the courier. A cart with ice cream and crackers sees neither the van (crackers are not frozen or chilled) nor the courier (ice cream is frozen), so WooCommerce shows its “no shipping options” message. A cart with only ice cream sees the van. A cart with 3 bottles of wine is told to add more, and a cart with 3 sale items is told to remove one. A cart with no wine at all is not asked for any: a minimum applies only once the cart holds an item from that category.
Set it up
- Install the free ReachZone plugin and the Delivery Slots add-on (download it from your ReachZone account page and install it under Plugins, Add New, Upload Plugin). Enter a Pro, Business or Agency licence in the ReachZone settings. Category rules need add-on version 0.5.0 or later. See pricing.
- In WordPress, open WooCommerce, then Delivery slots, and scroll to “Category rules”.
- Under “Shipping methods by category”, every enabled shipping method of your shipping zones is listed. For the courier, choose “Not for these categories” and tick “Frozen”. You can tick up to 50 categories per method.
- For the cold van, choose “Only for these categories” and tick “Frozen” and “Chilled”. Methods left on “All products (no rule)” are not changed.
- Under “Category limits at checkout”, click “Add a limit”. Choose “Wine” with “Minimum items” 6. Add a second limit for “Sale” with “Maximum items” 2. You can add up to 10 limits.
- Tick “Block checkout when a category limit is not met”. The limits do nothing until you do. You can change both messages.
- Click “Save delivery slots”.
- Test on your shop with a few carts: crackers only, ice cream and crackers, ice cream only, 3 bottles of wine, 3 sale items.
More notice for some categories
From add-on version 0.6.0, “Extra notice by category” delays slots and pickup times for carts with a category you choose. Click “Add a category”, choose it and set “Notice (hours)”, from 1 to 336. With 48 hours for “Custom cakes”, a cart with a cake is offered delivery slots and pickup times from two days ahead, and other carts keep the usual times. The longest notice in the cart applies. It needs delivery slots or pickup times, and checkout refuses a time that is too early.
Good to know
- A product counts as being in a category when it is in it or in one of its subcategories. Choosing “Garden” covers “Garden > Seeds”. A variation follows its product. A product with no category never matches, so it breaks an “Only” rule.
- Limits count items by quantity over the whole cart, whatever shipping method is chosen. They count every item, including virtual ones.
- If a rule hides every method, WooCommerce shows its own “no shipping options” message. The add-on has no text of its own for this.
- A classic “Local pickup” method can have a rule. The block checkout’s Local Pickup locations cannot, and they are not listed.
- Rules go by category only, not by product or tag.
- If categories cannot be read, the methods are left as they are, nothing is blocked and no notice is added.
- Related guides: block checkout outside your area and minimum order by zone. The same rules exist on Wix: see rules by product category on Wix.
Questions
Can I hide a WooCommerce shipping method for one category?
Yes, with a code snippet or with the add-on. In the add-on, choose “Not for these categories” on the method and tick the category. The method is hidden whenever the cart has an item in it.
Can I offer a method only for some categories?
Yes. “Only for these categories” offers the method only when every item in the cart is in a chosen category. One item outside them hides it.
Can I require at least 6 items from a category?
Yes, with a category limit. A minimum applies only when the cart has an item from that category, so carts without it are not blocked.
Does it work with the block checkout?
Limits are checked in the classic checkout and the block checkout. Methods are hidden from the shipping options both use. The only exception is the block checkout’s own Local Pickup locations, which cannot have a rule.
Do I need delivery slots?
No. Category rules and limits work without them. Only “Extra notice by category” needs slots or pickup times.
The add-on’s version history is on what’s new.