Hi everyone,
I’ll be grateful if someone can tell me if I can accomplish the following via code and how to do it. I have a rental business and customers can keep the items for as long as they want therefore I have a subscriptions app for recurring monthly payments. I’m using the “Track Quantity” function in Shopify so that items out of stock show the “Out of stock” tag. Imagine that I have 4 items in stock and a customer rents one of them, Shopify creates an order when the customer creates the subscription then the quantity is changed to 3. So far so good but if the customer keeps the item after one month then the subscription app charges his credit card again and Shopify creates a new order which in turn reduces the stock quantity to 2 but this adjustment is incorrect because out of the 4 items in total I have 3 in stock (and not 2) and the customer has 1. So the logic to correctly update the stock quantity depends on whether the order was created due to a recurring payment or not. I have noticed that each order has a tag which can be either recurring_order or first_order. Therefore, the logic to fix the incorrect counting when an order is created would be something like (in pseudo code):
If order.tag = recurring_order then
For each product in the order
product.StockQuantity = product.StockQuantity + 1.
As you can see the logic seems quite simple but in which liquid file I can write this logic?
I heard about Shopify Flows which allows to implement certain logic without the need to code, could this be an alternative approach?
Thank you very much in advance for any ideas.
Miguel.