Magento 2 Free Shipping Except...

It's fairly easy to set up a free shipping promotional rule for carts that have more than X dollars in Magento 2. But we have a client that sells some items that are inexpensive but bulky so they needed to be able to exclude those items. So we set it up so there is a Yes/No Product Attribute flag that accomplishes this.

Note that the way this is set up involves using a double negative, which I prefer to avoid, but there is one issue we ran into that made it necessary: If you set up a Yes/No Product Attribute to have a default value of Yes, the rule will work for pre-existing products but when you open such products to edit them in the dashboard, for some reason the attribute will be set to No and if you save it without adjusting it, it will save the wrong way and break the intent of the rule. Perhaps this bug will be fixed in a future version of Magento. It is not an issue for new products.

So, set up the Product Attribute by going to Stores | Attributes | Product, click Add New Attribute and set the following properties:

  • Default Label: Disallow Free Shipping
  • Catalog Input Type for Store Owner: Yes/No
  • Default Value: No
  • Storefront Properties: Use for Promo Rule Conditions Yes

Save the Product Attribute.

Then, go to Stores | Attributes | Attribute Set and add the new attribute to the appropriate Attribute Set(s).

Finally, set up the Free Shipping rule by going to Marketing | Cart Price Rules, click Add New Rule and set it up like this:

Conditions:

If ALL of these conditions are TRUE:

  • Subtotal (Excl. Tax) equals or greater than 50
  • Product Attribute combination: If an item is FOUND in the cart with ALL of these conditions true:
    • Disallow Free Shipping is not Yes

Actions:

  • Apply Percent of product price discount
  • Apply to Shipping Amount Yes

Apply the rule only to cart items matching the following conditions:

  • If ALL of these conditions are TRUE:
    • Disallow Free Shipping is not Yes
  • Free Shipping For matching items only
<< All the things