Update Stock/Quantity for Warehouse (Product/Gift/Add-on Product)

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

Parameter

Type

Description

Example

id

  • Required

String

Product’s id
Gift’s id
Addon’s id
商品id / 贈品id / 加購品id

5d3594c276e7ec003b7021c0

warehouse_id

  • Required

String

Warehouse’s id
倉庫 id


Only warehouse with status "active" can be updated
只有 status “active” 的 warehouse stock 的可以更新

"warehouse_id"=5ee819deab591e00169a4618

quantity

  • Required

Number

Quantity
(新增/減少)商品數量

Negative number is allowed
允許更新庫存為負值

"quantity"=21

variation_id

String

Product Variation's id
若更新選項的庫存,請指定選項id

"variation_id"=5d3594c2e95d2f000642e011

is_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
增加/減少數量

"is_replace": false

Response Fields

Field

Type

Description

Example

id

String

Product’s id
Gift’s id
Addon’s id
商品id / 贈品id / 加購品id

5d3594c276e7ec003b7021c0

title_translations

Translation

Title translations
商品 / 贈品 / 加購品 名稱

Please check stock data below

stocks

Stock[]

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
       }
   ]
}