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 \
  https://open.shoplineapp.com/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"
}