Flow that detects if order has more than 3 free items

Solved

Flow that detects if order has more than 3 free items

Clochette
Tourist
7 0 4

Hi!

I can't figure out how to build a flow that will tag an order that had more than 3 free items in it (4+ items at $0 each). I can do 1 item but not sure how to do for more. They are not necessary the same SKU.

Thanks for helping!

Accepted Solution (1)

paul_n
Shopify Staff
1165 143 275

This is an accepted solution.

You can write some liquid in the tag itself to count the number of free items. Something like:

{% assign free_count = 0 %}

{% for li in order.lineItems %}

{% if li.discountedTotalSet.shopMoney.amount  <= 0 %}

{% increment free_count %}

{% endif %}

{% endfor %}

{%- if free_count >= 4 -%}YOUR_TAG{%- endif -%}

 

You may have to make that all fit on one line when you enter it into the tag field.

Paul_N | Flow Product Manager @ Shopify
- Finding Flow useful? Leave us a review
- Need Flow help? Check out our help docs.
- Building for Flow? Check out Flow's dev docs.

View solution in original post

Replies 3 (3)

JoesIdeas
Shopify Partner
2319 211 615

I don't know how to do this natively in Shopify but if you aren't able to find a solution and need a plan B, Order Automator app does a bunch of things like this. If there isn't an exact solution in the app, you can get free custom rules built to match your store's needs.

• Creator of Order Automator (automate tagging, fulfillment, Amazon, notifications + more)
• Shopify developer for 10+ years, store owner for 7 years
• I also make guides like Shopify Automation Tips and How to Figure Out Why You're Not Getting Sales

paul_n
Shopify Staff
1165 143 275

This is an accepted solution.

You can write some liquid in the tag itself to count the number of free items. Something like:

{% assign free_count = 0 %}

{% for li in order.lineItems %}

{% if li.discountedTotalSet.shopMoney.amount  <= 0 %}

{% increment free_count %}

{% endif %}

{% endfor %}

{%- if free_count >= 4 -%}YOUR_TAG{%- endif -%}

 

You may have to make that all fit on one line when you enter it into the tag field.

Paul_N | Flow Product Manager @ Shopify
- Finding Flow useful? Leave us a review
- Need Flow help? Check out our help docs.
- Building for Flow? Check out Flow's dev docs.
Clochette
Tourist
7 0 4

Thanks. I didn't even know I could add liquid code in there. Will try this 🙂