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 |
| Product or Product Variation sku | |
quantity |
| Quantity
| |
replace |
| Whether replacing the original quantity
| |
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 |
| Product's ID or Product variation's ID | 5a8165efe38809548f0000f8 |
sku |
| Product SKU | sku-123 |
quantity |
| Product's Current Quantity | 21 |
updated_at |
| Last Updated Time | 2018-02-23T04:17:15.544+00:00 |
product_id |
| Product's 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 13 days ago