Add Sale Tag when Compare at Price and Variant Price do not Match

ZLonergan
New Member
4 0 0

Hello. 

 

I am trying to create a Flow that looks at the Variant Price and the Variant Compare at Price. If the difference in price i greater than 1, then apply Sale Tag otherwise do nothing.

Replies 9 (9)

paul_n
Shopify Staff
957 128 226

You can compare those prices, but you cannot do math in a condition yet. 

 

You could potentially do that math using liquid directly in the tag action, which allows liquid. 

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.
ZLonergan
New Member
4 0 0

Thanks, Paul. Do you have any guidance on how to complete that? I am more of a business admin than a developer but can copy and paste with the best of them. 🙂 

paul_n
Shopify Staff
957 128 226

It's something like:

 

{%- assign current_minus_one = variant.price | minus: 1 -%}
{%- if variant.compareAtPrice <= current_minus_one %}Sale{% endif -%}

 

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.
ZLonergan
New Member
4 0 0

Thank you, Paul. Is there a walkthrough on how to setup this flow? I am not sure how/where to add your logic. Thank you!

paul_n
Shopify Staff
957 128 226

You would put that code directly in the add product tag action and hit enter. The structure would depend on when you need it to run, which would determine the trigger.

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.

Kalen_Jordan
Shopify Partner
447 15 64

Sounds like that math may not be possible in a condition with flow - if you're interested in considering MESA (3rd party shopify app) for this, but we can handle that math and tag logic - and I'd be happy to setup and test the workflow for your store for you.

ZLonergan
New Member
4 0 0

Thanks, Kalen. I just downloaded the app and would like to test through the free version. How would I build this flow? I have the trigger set to be when a product is updated - this should catch it. I've also got a temporary price metafield which is dependent upon a sale tag as well. I feel like the logic should be: If temporary price is not blank, then sale tag applied, if temp price is blank then if variant is on sale (difference between variant price and compare at price >1) then apply tag. If neither tests are true then remove the sale tag. Can this logic be done?

Kalen_Jordan
Shopify Partner
447 15 64

Nice! Yeah that sounds about right. You might need to loop over all the variants under the product if not doing that already.

 

I would have popped in and checked it myself just now but not sure what the name of your store is?

 

Also feel free to email me kalen@getmesa.com - I might be able to reply faster that way.

Kalen_Jordan
Shopify Partner
447 15 64

Out of curiosity what was the reason for the Sale tag in this case? Seems you can do an automated collection out of the box with just the compare at price...?