How to adjust stock quantity when certain orders are created

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.

Hi @Mike5241

You got it right any kind of data saving activity needs APP access.

Therefore this can’t be possible via liquid code and Shopify flow is the best option you have to accomplish the task if you are on Shopify advanced package or you can go for the custom APP too.

Hi Gr_trading,

My apologies for the late reply, unfortunately I have the Shopify Basic plan.

I’m sorry about the perhaps silly question but what do you mean by “needs APP access” and “custom APP”? You mean the only choice is to install an inventory management app for this?

Thank you,

Mike

Yes Mike, apps are of two type 1 which we download from the Shopify’s App Store.

2 developer like us create for specific vendor for their special need call custom app.