Install
This is the repository archive. It installs, but the folder name will carry the branch suffix and updates will not flow.
Install straight from GitHub with WP-CLI:
wp plugin install https://github.com/unlocnl/shipping-class-restrictions/archive/refs/heads/main.zipOn Packagist as unloc/shipping-class-restrictions:
composer require unloc/shipping-class-restrictionsRestrict WooCommerce shipping methods by the shipping classes in the cart, per method instance and zone. Works with any third-party method.
Description
Adds two fields to every shipping method's settings (in the zone editor):
- Availability: a single rule choosing when the method shows, based on the classes in the cart
- Shipping classes: which classes the rule applies to (including "No shipping class")
Availability options:
- Show only if cart contains only these classes
- Show if cart contains any of these classes
- Hide if cart contains any of these classes
- Hide if cart contains only these classes
For example, a letterbox-only method can be set to "Show only if cart contains only [letterbox]", while the default parcel method is set to "Hide if cart contains only [letterbox]" — so the parcel method disappears for an all-letterbox cart but returns as soon as a parcel item is added. Because configuration is per method instance, it is inherently scoped to the shipping zone the instance belongs to.
Changelog
1.0.0
- Initial release.