Re: Creating workflow that put a product into collection based on price reduced by %

Topic summary

A user seeks to automatically add products to a “Final Sale” collection when their sale price is reduced by 50% or more, and display a non-returnable notice before checkout. Shopify’s native collection conditions only support dollar amounts, not percentages.

Proposed Solution:

  • Use Shopify Flow to calculate discount percentages and store them in a product metafield (type: Decimal)
  • Create an automated collection that filters products based on this metafield value (≥50%)
  • The helper provides a Liquid code snippet that calculates the maximum discount percentage across product variants

Implementation Challenges:

  • The workflow only triggers on future product updates, not existing inventory
  • A backfill workflow is needed to process current products with existing discounts
  • Updating metafields causes products to re-trigger the workflow (a known issue being addressed by Shopify)
  • The workflow appears to run on random products every 10 minutes rather than only price-changed items

Recommended Fix:

  • Switch from “Get product data” to “Get product variant data” to prevent metafield update loops
  • Manually set metafields for existing discounted products or create a separate backfill workflow
  • Theme customization (outside scope of discussion) needed to display “Final Sale” notices

Status: Ongoing troubleshooting; the user reports the workflow isn’t functioning as intended despite being activated.

Summarized with AI on November 1. AI used: claude-sonnet-4-5-20250929.

Hi There

i need to push product into a collection “Final Sale” with a condition set that if the sale price is less by 50% or more , that product will appear in collection called “FINAL SALE” or “LAST CHANCE” and before customer added to the cart it will say the following “Final sale. This item cannot be returned/exchanged” it cannot be done trough regular shopify , since its dose not allow me to put condition based on % only $

This template sets a metafield value if something is on sale. https://shopify.com/admin/apps/flow/editor/templates/01905f6c-7315-716b-bbd3-6e085afc7048

You could adjust it to insert the sales percentage instead and then check that in your collection

Hi Paul

thank you again for your help, i get this popping up, how do i define this ?

"Pre-install note:

  • To use this workflow, first define a boolean metafield to track product variants that are on sale. Then specify a namespace and key for the metafield.

can you explain on what this workflow will do ? will it add the product to a specific collection ? will add notation that this item is final sale ?

last time i was working with flow was a year ago , i am a bit rusted , could you please edit the flow to do it on 50% or more ? i do apricate all your help

You need a product metafield that is a type Decimal:

Hi Paul thank you again , i just created that metafiled

i changed the name space to custom.50_discount since i may do another flow with a regular discount

so what should i do now ?

This is how I set up the metafield in that workflow:

And this is the code I used, which seems to work but definitely test. It assumes you have a “compare at price” and it outputs a number for the % off the “price” field is for the most-discounted variant (if the product has more than 1 variant).

For example, if a product was usually 100 and now 80, it would output 20.00. You could then check that value in your collection.

{%- assign max_discount = 0 -%}
{%- for variants_item in getProductDataForeachitem.variants -%}
{%- assign discount = variants_item.compareAtPrice | minus: variants_item.price | divided_by: variants_item.compareAtPrice | times: "100" -%}
{%- if  discount > max_discount -%}
{%- assign max_discount = discount -%}
{%- endif -%}
{%- endfor -%}
{{- max_discount | round: "2" -}}
1 Like

Hi Paul

again thank you very much for your help

sorry for my ignorance, this code will authomatcily set up if any item is reduced by 50% or more it would go to a collection called final Sale ? or do i need to edit it ? and if yes what part do i need to edit

since the sample above is for 20% discount, an i right ? and also i do not see where dose it added it to a collection

also i don’t see where would it mark the product as final sale , again i really do apricate it all your help

This code outputs the discount (e.g., 20%) of the most discounted variant.

If you want the collection to use 50%, then you would put that in your collection criteria:

One note - this will only affect price updates going forward. And if you have more than 100 product updates per 10 minute it will miss some (due to limits in Flow)

Hi Paul

ok i create that collection , however no products been added to the collection

i do have products that the sale price is more than 50% discount, however when i created the collection no products been added

can you let me know what am i doing wrong ?

for example this is one product https://nyck.com/search?q=JESSICA+SIMPSON+CADILYN

also i want to know how can i set products with the above to have a comment stating that the product is FINAL SALE

Thank You

As I said in the note, the workflow will only work for products that are updated in the future. So over time, you should see more and more products show up there.

If you want it to work on all existing products, you either need to build a second workflow to use to backfill the metafield value. Or you could fill in the value manually.

Probably the simplest option to automatically backfill would be to duplicate the workflow, and then change the “get product data” action to get any product that doesn’t have a certain tag like “flow-sale-metafield”. Then in the workflow you update the metafield for each (same way). You would need to add a second loop to add that product tag (so it doesn’t get picked up again by the query). Like this:

If you want to add a “Final sale” comment, you likely need to edit your theme file to use that metafield (or collection) and display the text.

Hi Paul ok i guess i did not explained my self well , my apology

the final sale collection would not be for products that just been created , since we are not bringing new products to put in a final sale collection , obviously we would sell it at regular price first, than reduce it a bit and than we will put it at 50% and above

so the flow you created would not work for me , i need a work flow to be on products that the prices changed, and not on product that just created , there is away you can send me a revised code that i can update it

as to the final sale comment i would apricate it if you can send the the steps on how can i create the final sale comment,

i assume i have to go to theme setting , but from there i need a more detail instruction

again i know i am asking a lot probably its also outside of your support , so i do apricate all your help

Thank You

Editing your theme is outside what I can help with and theme dependent.

The workflow you have should work for any product that is updated after the workflow went live (not just for “new” products).

The gap you might want to fill is for existing products that haven’t been edited yet, but which are actually on sale. If that’s a small number, I would recommend going into the products in the Admin and setting the metafield (you need to pin it for it to show in the Admin).

Hi Paul,

Thank you again for your response.

Before replying to your last message, I realized I forgot to mention that I did reduce the price of the shoe, as you suggested, from $49.95 to $39.95, to see if it would trigger the collection update. However, it still hasn’t added the product to the collection.

If it’s not too much trouble, would you mind reviewing the code to see if we might be missing a step? I’d really appreciate your help with this!

Thanks again!

Not sure if the code is the problem - what did you see in the workflow run? Did it find the changed product? Did it update the metafield?

As far as I can tell, you haven’t turned this workflow on, or adjusted the schedule to run in the future.

Hi Allen

the flow was turned on and it was set to start in the feature

i see the flow is runing by is doing the task on prducts that are not within the critira, menaing that its just doing random items 10 at the time every 10 minutes , for products that never change in price or the diffrence is not more than 50% , i do not know the logic is this flow , but its not doing what i want it to do ,

from what i understand it will proform this taks only on products that had some kind of movement , either they just been added or they just been edited , however none of the products been added or been edited

Please advise

Thank You

One thing I discovered in testing - if you update a metafield it causes a product to be updated. Which makes it show up in this workflow again. And then you update it again to the same value, it will happen again. The metafields team is working on fixing that second part.

The solution for now is to change “Get product data” to “Get product variant data”. Copy the “query” from the other task into it first. This actually is a better design since the pricing changes happen on a variant anyway and when you update a product metafield it won’t cause this to run again. Once you do that, you need to refactor your condition because you’ll have a list of variants instead of a list of products. It will look like this:

Hi Paul

thank you for the reply , but i cannot edit the file, unless you mean that i need the delet the original one and copy the old one and do the above changes , would’t be easier just to give me the correct formula, since i know i will make mistake somewhere

again the original flow did not work me, and its running on some products that shold not be running, again thank you for all your help