Update Product, Product Variation Quantity by SKU
Notice 提醒
Product unlimited_quantity should be false
商品 無限數量 需要設定為 false
Function
Update product or product variation quantity by SKU
使用商品貨號更新商品或商品規格庫存數量
URL
PUT <<api_domain>>/v1/products/update_quantity
Request parameters
Parameter | Column Type | Description | Example |
---|---|---|---|
sku | String | Product or Product Variation sku 商品或商品規格的商品貨號 | ruby "sku": "sku-123" |
quantity | Integer | Quantity (新增/減少)商品數量 - *if replace sets as false, allows quantity to be negative number 如果 replace 為 false,准許 quantity 為負數 | ruby "quantity": 10 |
replace | Boolean | Whether replacing the original quantity 是否取代原本數量 - _true: replace the product's quantity with the number you provided 取代原本數量_false: increase/decrease the quantity with the number you provided 增加/減少數量 *Default: true | ruby "replace": true |
Request Example
curl -X PUT \
'<<api_domain>>/v1/products/update_quantity' \
-H 'Accept: application/json' \
-H 'Authorization: Bearar {{access_token}}' \
-H 'Content-Type: application/json' \
-d '{
"sku": "sku-123",
"quantity": 21,
"replace": true
}'
curl -X PUT \
https://open.shoplineapp.com/v1/products/update_quantity \
-H 'Accept: application/json' \
-H 'Authorization: Bearer {{access_token}}' \
-H 'Content-Type: application/json' \
-H 'User-Agent: shopline' \
-d '{
"sku": "sku-123",
"quantity": -1,
"replace": false
}'
Response fields
Field | Column Type | Description | Example |
---|---|---|---|
id | String | Product's ID or Product variation's ID 商品或商品規格的ID | 5a8165efe38809548f0000f8 |
sku | String | Product SKU 商品或商品規格的商品貨號 | sku-123 |
quantity | Number | Product's Current Quantity 商品或商品規格的數量 | 21 |
updated_at | DateTime | Last Updated Time 最後更新時間 | 2018-02-23T04:17:15.544+00:00 |
product_id | String | Product's ID 主商品ID (如果更新的項目為商品規格才會顯示) |
Response Example
{
"id": "5a8165efe38809548f0000f8",
"sku": "sku-123",
"quantity": 21,
"updated_at": "2018-02-23T04:17:15.544+00:00"
}
{
"id": "5a8165efe38809548f0000f8",
"sku": "sku-1234",
"quantity": 1,
"updated_at": "2018-12-25T04:52:25.279+00:00",
"product_id": "5bd7e5b5e388091b1c5a5f9b"
}
FAQ
- 如果想更新數量的 SKU 在 EC Admin 不存在,會有對應 error 嗎?
有,請見下方範例。
{
"error": "Not found.",
"code": "NotFoundError",
"caused_by": null
}
-
如果 SKU 在 EC Admin 對應到多個商品/商品規格
全部都會被更新成 Open API 打的指定庫存結果。
-
打完數量更新後,Open API 回覆的 quantity 是指更新後的數量嗎?
對。
-
如果是無限庫存不可以更新庫存,會有對應 error 嗎?
有,請見下方範例。
"errors": [
{
"id": "63a9161244525f0020c49337",
"message": {
"error": "Do not allow to update quantity of the product which contains one or multiple products or has unlimited quantity.",
"code": "QuantityUpdateNotAllowedError",
"caused_by": null
},
"status": 403
}
]
Updated 12 months ago