Have your say in Community Polls: What was/is your greatest motivation to start your own business?

How can I automate tag creation based on discounted price in Flow?

How can I automate tag creation based on discounted price in Flow?

JonLane
Visitor
2 0 0

Hi - I want to create a flow that auto creates a tag based on the discounted price of a product - so it would need to do a calculation [(price / compare at price) - 1] - is this possible?

 

any advice gratefully received!

 

thanks

Replies 3 (3)

paul_n
Shopify Staff
1429 156 330

Yes, possible. You likely need to put Liquid in the tag field (and hit enter to save the tag). Something like:

 

{{ productVariant.price | divided_by: productVariant.compareAtPrice | minus: 1 }}

One note...depending on the trigger you may not have access to productVariant, or you'll need to loop over lineItems (for orders) or variants (for product triggers)

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.
JonLane
Visitor
2 0 0

Hi Paul - great - I want to round the discount level in the tag but am getting an error 

  • {{{{ productVariant.price | divided_by: productVariant.compareAtPrice | minus: 1 }} | round: 2 }}
 
Liquid syntax error: Unexpected character { in "{{{{ productVariant.price | divided_by: productVariant.compareAtPrice | minus: 1 }}"


Any help gratefully received!
lilyliward
Shopify Staff
19 1 9

I think you need to move the round inside the curly brackets. Try:

 

{{ productVariant.price | divided_by: productVariant.compareAtPrice | minus: 1 | round: 2 }}

To learn more visit the Shopify Help Center or the Community Blog.