Managing Magento shipping rules effectively is key to running a successful store. Whether you need to offer free shipping for specific products, restrict certain methods based on location, or set dynamic shipping conditions, configuring rules properly can streamline operations and enhance the customer experience.
However, small errors in setup can lead to conflicts, incorrect shipping options, or unintended costs. In this guide, we’ll explore the fundamentals of Magento shipping rules, highlight common mistakes, and provide actionable solutions to help you optimize your store’s shipping logic.
Common Mistakes in Shipping Rules Magento 2
Many of our clients frequently reach out with questions about configuring rules in Amasty modules. To help them effectively utilize the rules logic and avoid common pitfalls, we’ve compiled a list of the most common mistakes based on Amasty support queries.
Magento 2 Restrict Shipping Locations: Rules Overlap
The most common issue arises from setting up overlapping shipping restriction rules that contradict one another. For example, a merchant may create one rule to block certain shipping methods for specific regions and another rule that unintentionally overrides or conflicts with the first.
Problem
Say you need to make Free Shipping available for all US states except Alaska, Hawaii, and Puerto Rico. Alaska, Hawaii, and Puerto Rico will have the flat rate method displayed instead of the free method. Only the flat rate method will be displayed for Alaska, Hawaii, and Puerto Rico, not for other states.
You need to:
(a) Enable Flat Rate and restrict Free Shipping for Alaska, Puerto Rico, and Hawaii, and
(b) Restrict Flat Rate and enable Free Shipping for all the states except Alaska, Puerto Rico, and Hawaii.
You go and set up Rule 1 to exclude Free Shipping to Hawaii, Alaska, and Puerto Rico. And this works fine. Then you set up Rule 2 to hide Flat Rate shipping to any state except Alaska, Hawaii, and Puerto Rico. This is not working at all. It is just hiding the flat rate method for all states.
The case seems logical. However, the conditions repeat the code branches and can return True
if all the conditions or one of them is fulfilled. Thus, you messed up.
Analysis
There are no obstacles to applying the Magento Free Shipping rule to all states while restricting Hawaii, Alaska, and Puerto Rico.
And all the steps you made are right:
Thus, you restrict any free shipping to any of the three states.
The problem emerges when you create Rule 2 or Flat Rate restriction for 48 states on the same basis:
The difference between the previous and this screenshot is that you changed True to False. It seems logical, however, this is what you receive, as the result - Rule 2 worked correctly, restricted Flat Rate, and returned Free Shipping:
Rule 1 failed, restricted Free Shipping, and didn’t activate the Flat Rate:
Thus, you see that Rule 1 didn’t work and go to make edits to it. Having disabled Rule 2, you understand that Rule 1 works correctly. Then you proceed with Rule 2, you start sorting conditions or even change False to True and ‘is’ to ‘is not’. As a result, you change nothing in the work of the rules.
Solution
All you need is to go to Rule 2 and change Any to All:
- When there’s Any, the rule returns
True
for the first condition already, and the code doesn’t execute further. - Thus, the code partially worked for the first of the three states (e.g.: Hawaii) and didn’t at all for Alaska and Puerto Rico.
Magento 2 Free Shipping for Specific Products: Rules Ignored or Misapplied
Issues can often occur when applying Free Shipping to specific products without accounting for cart-level conditions or other product types. Merchants sometimes configure rules too broadly, applying Free Shipping to all products in a category or neglecting to exclude non-eligible products. Similarly, mixing product-level and cart-level conditions without prioritization can lead to rules being ignored or misapplied.
Problem:
For example, you want to offer Free Shipping on specific products identified by their SKU or category. However, if you create a condition that inadvertently includes all products in the cart when one qualifying product is present, Free Shipping may apply incorrectly to non-eligible items.
Solution:
- Use precise conditions, such as SKUs, product attributes, or categories, to identify products eligible for Free Shipping.
- Include exclusions for products or categories that should not be eligible for Free Shipping to avoid unintended applications.
- Avoid combining product-specific rules with cart-level rules unless you clearly define priorities. For instance:
- Rule 1: Offer Free Shipping only if the cart contains specific products with an SKU or category match.
- Rule 2: Apply cart-level Free Shipping only when the subtotal exceeds a defined threshold, excluding any non-eligible products from the calculation.
Magento 2 Shipping Method: Overlapping Rules with Multiple Carriers
Using multiple shipping carriers with conflicting rules for the same shipping zones. For instance, one carrier offers Free Shipping under specific conditions, while another applies Flat Rate, leading to both methods being displayed or neither working as expected.
Problem:
When shipping rules are not configured to handle specific carriers or zones independently, the system can interpret overlapping conditions incorrectly, resulting in customer confusion or cart errors.
Solution:
- Assign carrier-specific rules and ensure no overlap in zones or conditions.
- Test how each carrier behaves independently before introducing combined rules.
- Use clear prioritization in the rule logic, ensuring rules are applied sequentially without ambiguity.
Common Shipping Rules Mistakes in Magento 1
While Magento 1 is an outdated platform, and we strongly recommend upgrading to ensure security and proper rule functionality, we’ll briefly review common Magento shipping rule mistakes and their solutions for this version as well.
1. 'IS' in condition with lists
If you use conditions as in the picture above, Magento will search for the '17,15,12,44' category ID. Naturally, we don't have such a category, and we actually need another result. Here's the right variant:
Here Magento will be searching for these IDs: '17', '15', '12', and '44' and the stated Amasty rule will work as desired.
2. Compare with zero
At first sight, this condition looks legit. But there's a technical issue: basically, you should avoid comparing with zero everywhere in Magento, not only in sales or shipping rules.
The following condition is identical logically and, what is more important, it will work correctly.
3. 'greater than' condition operator
Sometimes people use > or < symbols to describe amount comparison relations, but Magento won't understand them properly. Use a special conditions operator instead:
4. Range/list
Very often we notice that Magento shop owners use 'range' when they need Magento to apply something to a list of items. This is wrong, and Magento won't understand this combination as a range. You need to list items (in our case - SKUs) one by one using a comma. And yes, 'is/is one of' case shown once again.
However, there are a few clients who use manual listing of all the post-codes, therefore, for post-code ranges we normally use the operator ‘starts from’ and, if needed, ‘ends with’.
5. Default shipping address vs Shipping State/Province
Names can't be used with the default shipping address, you need to use the default shipping ID instead. Literal location names are used with Shipping state/Province entities.
Conclusion
Magento is a powerful rule engine but to use most of it you need to know how to configure it right. We do hope this information will be helpful for you, and you'll never make these mistakes again!
If you have any other questions on typical conditions logic mistakes, welcome to ask in the comments.