HomeGuidesAPI ReferenceChangelogDiscussions
HomeLog In
Guides

Update Stock (Product/Gift/Add-on Product)

❗️

Notice

Only available to POS enabled merchants.
僅提供使用 POS 的店家使用。

Function

To update the product's/ gift's/ add-on product's stock with its ID
使用商品 ID 更新商品/ 贈品/ 加購品在各個倉庫的庫存

URL

Product stock: PUT <<api_domain>>/v1/products/:id/stocks
Gift stock: PUT <<api_domain>>/v1/gifts/:id/stocks
Add-on stock: PUT <<api_domain>>/v1/addon_products/:id/stocks

Request Parameters

ParameterTypeDescriptionExample
id
*Required
StringProduct’s id
Gift’s id
Addon’s id
商品id / 贈品id / 加購品id
5d3594c276e7ec003b7021c0
warehouse_id
*Required
StringWarehouse’s id
倉庫 id
-----
Only warehouse with status "active" can be updated
只有 status “active” 的 warehouse stock 的可以更新
"warehouse_id"=5ee819deab591e00169a4618
quantity
*Required
NumberQuantity
(新增/減少)商品數量

Negative number is allowed
允許更新庫存為負值
"quantity"=21
variation_idStringProduct Variation's id
若更新選項的庫存,請指定選項id
"variation_id"=5d3594c2e95d2f000642e011
is_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
增加/減少數量
"is_replace": false

Response Fields

FieldTypeDescriptionExample
idStringProduct’s id
Gift’s id
Addon’s id
商品id / 贈品id / 加購品id
5d3594c276e7ec003b7021c0
title_translationsTranslationTitle translations
商品 / 贈品 / 加購品 名稱
Please check stock data below
stocksStock[]Each stock
各倉庫的庫存
Please check stock data below

Response Example

{
   "id": "5ef1e5cbf1159c004ed9e789",
   "title_translations": {
       "zh-hant": "測試商品*"
   },
   "variations": [
       {
           "id": "5ef1e5cb214bbc0013813cfd",
           "fields_translations": {
               "en": [
                   "s"
               ],
               "zh-hant": [
                   "s"
               ]
           },
           "stocks": [
               {
                   "warehouse_id": "5e83216e2e4f81001e756014",
                   "quantity": 0
               },
               {
                   "warehouse_id": "5e831cb68fa5fc000f9925ab",
                   "quantity": 0
               }
           ]
       },
       {
           "id": "5ef1e5cb214bbc0013813cfe",
           "fields_translations": {
               "en": [
                   "m"
               ],
               "zh-hant": [
                   "m"
               ]
           },
           "stocks": [
               {
                   "warehouse_id": "5e83216e2e4f81001e756014",
                   "quantity": 0
               },
               {
                   "warehouse_id": "5e831cb68fa5fc000f9925ab",
                   "quantity": 0
               }
           ]
       }
   ]
}
{
   "id": "5ef1e613560e8e2166ce2f03",
   "title_translations": {
       "zh-hant": "測試商品"
   },
   "stocks": [
       {
           "warehouse_id": "5e83216e2e4f81001e756014",
           "quantity": 0
       },
       {
           "warehouse_id": "5e831cb68fa5fc000f9925ab",
           "quantity": 0
       }
   ]
}