我很难从数据库中获取我的woocommerce页面上的产品库存/产品数量。我能够获取其他部分(例如客户注释)来成功更新,但是不确定我在做什么错。
这是我尝试过的最近代码
* 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
非常感谢您的帮助!
没有名为inventory_quantity
的属性,请参见http://woocommerce.github.io/woocommerce-rest-api-docs/#product-properties
我想你想要的是stock_quantity