0

I am having difficulty getting the product stock/product quantities to update on my woocommerce page from my database. I was able to get other portions (like customer notes) to update successfully, but am unsure what i'm doing wrong.

This is the recent code i've tried

* The following code creates the JSON request body.
                * The JSON created by this code is shown below.
                loJsonReq = CreateObject('Chilkat_9_5_0.JsonObject')
                loJsonReq.UpdateNumber("product.id","3341")
                loJsonReq.UpdateBool("product.inventory_quantity",5)

                * The JSON request body created by the above code:

                * {
                *   "product": {
                *     "id": 3341
                *     "inventory_quantity": 5
                *   }
                * }

                loSbReq = CreateObject('Chilkat_9_5_0.StringBuilder')
                loJsonReq.EmitSb(loSbReq)

                loRest.AddHeader("Content-Type","application/json")

                loSbJson = CreateObject('Chilkat_9_5_0.StringBuilder')
                lnSuccess = loRest.FullRequestSb("PUT","/admin/products/#{id}.json",loSbReq,loSbJson)
                IF (lnSuccess <> 1) THEN
                    ? loRest.LastErrorText
                    RELEASE loRest
                    RELEASE loJsonReq
                    RELEASE loSbReq
                    RELEASE loSbJson
                    CANCEL
                ENDIF

                IF (loRest.ResponseStatusCode <> 200) THEN
                    ? "Received error response code: " + STR(loRest.ResponseStatusCode)
                    ? "Response body:"
                    ? loSbJson.GetAsString()
                    RELEASE loRest
                    RELEASE loJsonReq
                    RELEASE loSbReq
                    RELEASE loSbJson
                    CANCEL
                ENDIF

I'd appreciate any help!

1 Answer 1

1

There is no property named inventory_quantity see http://woocommerce.github.io/woocommerce-rest-api-docs/#product-properties

I imagine what you're after is stock_quantity

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.