Magento 2 Shipping Rules: Avoid Common Mistakes and Optimize Your Store

Table of Content

Magento shipping rules

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:

IS in conditions - correct

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

Compare with zero in Magento rules - wrong

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.

Compare with zero in Magento rules - correct

 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:

Greater than conditions operator in MagentoGreater than conditions operator - correct

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.
Range/list in Magento conditionsRange/list in Magento conditions - correct

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.

Default shipping address condition in Magento - wrongShipping address condition in Magento - correct

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.

July 17, 2019
July 25, 2019
July 12, 2019
Comments
Andhi Irawan
December 2, 2015
Can we use Shipping Postcode as Conditions for Shopping Cart Rule in Shopping Cart Page?
Reply
Ksenia Dobreva
December 2, 2015
Yes, you can. Please see the screenshot: <img src="https://amasty.com/blog/wp-content/uploads/2014/04/OkvX309.png" alt="" />
Andhi Irawan
December 4, 2015
Hi, Ksenia, Thank you. It works. I just found out about it (we can use postcode in shopping cart page as condition for rule)
Ksenia Dobreva
December 4, 2015
Great! Was happy to help.
sakis
November 18, 2016
Hello Ksenia very usefull article, We face a probelm with catalogue price rules. After one day rules doesnt work and we need to click apply rules button from backened almost every day. Is this a magento bug or something that we made wrong? Thanks
Reply
Ksenia Dobreva
November 18, 2016
Hey there, please make sure that your cron is working fine.
sakis
November 18, 2016
Thanks for reply, i set the cron every fove minutes like the line below
Reply
Ksenia Dobreva
November 18, 2016
Well, looks like it was our best guess... As the issue isn't connected with any of other extensions, I'm afraid I can't really help you here, it could be anything, and it's hard to tell from there without seeing the settings and stuff. Maybe you should ask a developer to have a look? Good luck with that.
Kenny
January 18, 2018
Can you provide more information about the comparing against zero problem? I googled but couldn't find anything related. I have noticed this problem using another extension that has conditions for an action. Basically I had to use Less than 1.
Reply
Alina Bragina
January 22, 2018
Hi Kenny, thanks for your question! Unfortunately, for the lack of info about your ‘comparing against zero’ problem it’s hard to resolve it from here. Could you, please, spell out the details, so we see what we can do. Cheers!
Dang Ton
June 4, 2019
Hello, I am late to the party but is there any chance that you show us how to set one Shipping Rule triumphs the others ? As of now, it doesn't give any option since it confuses. Thankss
Reply
Alina Bragina
June 18, 2019
Hi Dang, thanks for writing to us! You're not late to the party at all, just this month we're going to update the post and this info will covered this time. So, <a href="http://eepurl.com/Mv5tD" rel="nofollow">subscribe to our newsletters</a> or check the blog updates to find it in time.
Guest
October 29, 2019
3.5
Reply
Guest
October 29, 2019
1.5
Reply
Gianluca
October 1, 2020
Hi I have to check if the shipping address of the second order (and subsequent) is the same as the first one, in this case the shipping will be free.
Reply
Leave your comment

Your email address will not be published

This blog was created with Amasty Blog Pro

This blog was created with Amasty Blog Pro

Loading
Loading