HomeGuidesAPI ReferenceChangelogDiscussions
HomeLog In
Guides

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

ParameterColumn TypeDescriptionExample
skuStringProduct or Product Variation sku
商品或商品čĻæ ŧįš„å•†å“č˛¨č™Ÿ
ruby "sku": "sku-123"
quantityIntegerQuantity
(新åĸž/減少)商品數量

- *if replace sets as false, allows quantity to be negative number
åĻ‚æžœ replace į‚ē falseīŧŒå‡†č¨ą quantity į‚ēč˛ æ•¸
ruby "quantity": 10
replaceBooleanWhether 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

FieldColumn TypeDescriptionExample
idStringProduct's ID or Product variation's ID
商品或商品čĻæ ŧįš„ID
5a8165efe38809548f0000f8
skuStringProduct SKU
商品或商品čĻæ ŧįš„å•†å“č˛¨č™Ÿ
sku-123
quantityNumberProduct's Current Quantity
商品或商品čĻæ ŧįš„數量
21
updated_atDateTimeLast Updated Time
最垌更新時間
2018-02-23T04:17:15.544+00:00
product_idStringProduct'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

  1. åĻ‚æžœæƒŗ更新數量įš„ SKU 在 EC Admin 不存在īŧŒæœƒæœ‰å°æ‡‰ error 嗎īŧŸ

    有īŧŒčĢ‹čĻ‹ä¸‹æ–šį¯„䞋。

{
    "error": "Not found.",
    "code": "NotFoundError",
    "caused_by": null
}
  1. åĻ‚æžœ SKU 在 EC Admin 對應到多個商品/商品čĻæ ŧ

    全部éƒŊ會čĸĢ更新成 Open API 打įš„指厚åēĢ存įĩæžœã€‚

  2. 打厌數量更新垌īŧŒOpen API 回čĻ†įš„ quantity 是指更新垌įš„數量嗎īŧŸ

    對。

  3. åĻ‚果是į„Ąé™åēĢ存不可äģĨ更新åēĢ存īŧŒæœƒæœ‰å°æ‡‰ 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
        }
    ]