I want to update a collection by calling HTTPS. I have successfully downloaded data, but
I cannot get the examples given to work here. I want initially to change just the stock level.
This is my attempt:
export async function post_test() { let response = { "headers": { "Content-Type": "application/json" } }; let sName = ""; await wixData.get("Stores/Products", "6e027153-7052-4f61-b08c-c7eb29a97932") .then( (result) => { result.trackinventory = false; result.quantityInStock = 999; // get name to prove ID is correct sName = result.name; wixData.update("Stores/Products", result); } ); response.body = { "status" : "Run Complete", "name" : sName }; return ok(response); }
The response stuff is just to check it actually runs.
I have tried all examples but it does not update the database.
I have used the wixData.query route as well.
I have spend days trying to get it to work!
Can anyone help?
Lawrence
hi Lawrence,
This is not blog related question. Try Velo Forum https://www.wix.com/velo/forum or contact Wix Support.
Thanks, I got that to work. but I want to update the stock level.
I tried this from the example:
let sInvID = "91fd8eac-8fad-b09e-4f73-3814d65686cd"; let sID = "6e027153-7052-4f61-b08c-c7eb29a97932" let oData = { "trackQuantity": true, "variants": [{ "inStock" : true, "quantity": 999999, "variantId": sInvID }] }; await updateInventoryVariantFields("", oData)
but does nothing.
Can you help me?
Lawrence
Hi Lawrence,
Stores collections are read only, therefore update does not work. You can check Velo documentation:
https://www.wix.com/velo/reference/wix-stores
https://www.wix.com/velo/reference/wix-stores-backend
or try asking in Velo Forum https://www.wix.com/velo/forum .