We're moving the community! Starting July 7, the current community will be read-only for approx. 2 weeks. You can browse content, but posting will be temporarily unavailable. Learn more

How to adjust stock quantity when certain orders are created.

How to adjust stock quantity when certain orders are created.

Mike5241
Explorer
60 0 13

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.

Replies 3 (3)

gr_trading
Shopify Partner
2070 149 212

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.

For any custom development WhatsApp or connect at Email ID: support@grtrading.in for quick consultation. | Shopify Free codes
To support Buy Me a Coffee
Mike5241
Explorer
60 0 13

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

gr_trading
Shopify Partner
2070 149 212

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.

For any custom development WhatsApp or connect at Email ID: support@grtrading.in for quick consultation. | Shopify Free codes
To support Buy Me a Coffee