Calculate Low stock for limited products and set product tag

We do have limited products, which means that e.g. we’re only producing 1.500 pieces of one product. This number of limitation verifys.

So our full stock would be the number of limitation.

Product A has a limitation of 1.500 pieces

Product B has a limitation of 100 pieces

This information is on the product as a metafield.

Now i want to set a product tag as soon as the stock level is lower than 20%.

So i need to calculate it and the result should lead to setting the product tag once.

I didn’t figure out how to do this. Does anybody has an idea?

So for example you want to set a tag on product B when inventory is below 20? (20% of 100)?

If you’re interested in a 3rd party app, I should be able to build this out as a workflow for you with our app mesa.