Adding a Customer Tag IF they purchase $25 or more products with their own product tag?

pizzaSeth
New Member
6 0 0

Hello hello!

 

I'm trying to create a workflow that adds a customer tag to a user, only if the line items in their order with a specific tag totals $25 or more. Basically noting what types of products a customer buys for segmenting.

 

I'm using workflows and can get the IF TAG part, but I can't seem to find the magic recipe to determine the total cost of those specific items. I can only seem to get the total of their entire cart. Any suggestions?

 

I've been trying a handful of different tactics as tests. See image attached.

Screenshot 2023-05-26 at 8.03.13 AM.png

Replies 8 (8)
pizzaSeth
New Member
6 0 0

Go ahead and type your thoughts here! This is a community!

Mussty
Excursionist
34 3 7

instead of the order total amount maybe try the line item totals? 

 

Mussty_0-1685113594460.png

 

paul_n
Shopify Staff
927 127 222

To elaborate a bit- conditions evaluate if something is true or false. They do not filter a list that you can use in the next step. If you want to check that a line item has a tag AND the value for that line item is > 25, you need to have those both in the same condition block (click add criteria for same list item to add multiple conditions for a single line item)

 

If you need to total all of the lineItems that have tags and then check if the total is over $25, the only way to do that is via Liquid in the action itself (as Flow doesn't have the necessary filter/aggregate tools yet). So you would need to write liquid in the tag field (possible) that loops over the line items, checks tags, adds the values, etc.

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.
pizzaSeth
New Member
6 0 0

Thanks for the tip! I will give that a try and report back.

pizzaSeth
New Member
6 0 0

@paul_n Any advice? I keep getting errors (current is "final_line_price" is invalid. Replace this variable.), but I think I'm using the right properties based on the liquid documentation.

Any guidance is very much appreciated.

 

{% for line_item in order.lineItems %}

{ % if order.lineItems.product.tags contains 'Type: Chewy Candy' %}

{% increment line_item.final_line_price %}

{% if line_item.final_line_price > 25 %}

MORE_THAN_25_TEST

{% else %}

LESS_THAN_25

{% endif %}

{% endfor %}

paul_n
Shopify Staff
927 127 222

{ % if order.lineItems.product.tags contains 'Type: Chewy Candy' %}

You cannot access array items this way in Flow. You need to loop over each array. 

 

{% increment line_item.final_line_price %}

line_items isn't a variable and generally Flow doesn't use underscore for the available variables. Use "Add a variable" to see the right way.

 

{% if line_item.final_line_price > 25 %}

final_line_price is not a 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.
pizzaSeth
New Member
6 0 0

I'm curious if you know what the solution is, why you don't add it as a response instead of me struggling.

 

I don't know how to loop over each array or I would have done it.

paul_n
Shopify Staff
927 127 222

If you follow my suggestion to use "Add a variable" and choose a property inside lineItems, it will insert the loop for you. It will look something like:

 

{% for li in order.lineItems %}
{{ li.quantity }}
{% endfor %}

Otherwise, there are too many unknowns about your use case for me to build the solution for you. If you reread my initial response, I had to make a set of guesses about what your intention is. And the potential solution varies quite a bit based on your intention. 

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.