Change in stock items on test account

Hello
I am trying to change the stock quantity of selected items via a php action(I need to modify the stock quantity according to order (subtract the correct amount in accordance with the order)), unfortunately, I couldn't find the right materials in the documentation(I may have missed them).
After authentication at https://cloud.lightspeedapp.com/oauth/authorize.php?response_type=code&client_id=...&scope=employee:all
Then after receiving code `/gettokenls?Code=b70eaf72004e2001fe7452349584e6d4b76b9176`, and downloaded token.
I have added a sample item manually to `Items & Inventory` (https://us.lightspeedapp.com/?name=item.views.item&form_name=view&id=1&tab=details)
I checked the documentation https://developers.lightspeedhq.com/retail/endpoints/Item/ and https://developers.lightspeedhq.com/retail/endpoints/Order/
Unfortunately, I did not find any examples of changes in the storage quantity(how should I deduct quantities item now?), given in php
Can I ask someone from the team to guide me to the right solution for my problem, alternatively, please direct me to an example.
9 comments
This is interesting. Here below is my test API request URI and JSON body.
"https://api.merchantos.com/API/Account/{AccountId}/Item/55.json"
{
"Note": {
"note": "This is a newly-updated note."
},
"ItemShops": {
"ItemShop": {
"itemShopID": 164,
"shopID": 1,
"qoh": 1
}
}
}
All I'm doing is updating the note for ItemId 55 and changing the on-hand quantity to 1 for the first shop in the account.
When I look in the web client, I see the note was updated, and the site quantity is updated for the first shop. But the sum quantity available isn't updated. Screen shot below.
Assuming that I'm missing something in the JSON body, although I can't see where. Usually when you pull a record using the GET request, you can mimic the JSON body in the PUT request to update a record and get consistent results.
@Adrian Samuel do you have any input as to this?
Hey @spink90,
Greg's comment should suffice in providing an answer.
As he's shown , you'll need to specify the ItemShopID in the payload and then set the qoh field. You cannot deduct a number, you can only set a number.
So if for example you want to change qoh from 10 to 5, you'll have to do the math in your code and simply send in the payload, the "5" you want to set.
@gregarican, the reason your sum isn't updated because "In Stock" field is specified per store and not for all stores. You are logged in SawMill boutique whereas your stock is in MXC. If you change stores, you'll see the "In Stock" integer show correctly show
Hope this helps!
Adrian Samuel
Software Developer
Lightspeed HQ
Ahh I see. That makes sense now. Thanks @Adrian Samuel for the reminder. I thought the In Stock field was just a sum total across all shops. I'll file that one away for next time I have to work with this endpoint!
Hello
@Adrian Samuel
Thank you for your earlier reply.
But what happens if:
1) I have two applications
2) Both applications will want to deduct 1 at the same time
Does this mean that yours software will report incorrect inventory?
@gregarican
Thank you too for the answer
If you have two applications each making an API call to the same shop, to the same endpoint, and to same item, then Lightspeed Retail would logically reflect the requests. As long as no API thresholds have been exceeded then there are no surprises. Lightspeed Retail would only reflect what's been pushed into it via the API.
Out of curiosity, why would you have two applications in this scenario?
From GET
I get this answer
But when I try to change qoh (PUT)
I get this answer
Thank you in advance for help
I think it needs to be: