HomeGuidesAPI ReferenceChangelogDiscussions
HomeLog In
Guides

Add Product Variation

Function

Add a variation product under an existing main product.
在現有主商品之下新增規格商品

URL

POST <<api_domain>>/v1/products/:product_id/variations

Request Parameters

ParameterTypeDescriptionExample
default_show_image_selectorBooleanShow image selector on product details page 顯示選項圖片於商品頁面

default false
ruby default_show_image_selector: false
product_id
*Required
StringProduct ID
主商品ID
ruby 5d3594c276e7ec003b7021c0
variant_options
*Required
ArrayProduct Variations
商品規格
-
*Maximum allows 3 types of variant option for a product, type allow (color, size, custom_1, custom_2, custom_3)
最多支援三種不同的規格種類,支援color, size, custom_1, custom_2, custom_3
ruby "variant_options": [ { "name_translations": { "zh-hant": "綠", "en": "green" }, "type": "color",}, { "name_translations": { "en": "L1", "zh-hant": "大1" }, "type": "custom_1",}, { "name_translations": { "en": "Long1", "zh-hant": "長1" }, "type": "custom_2",} ]
location_idStringLocation ID
儲位編號
ruby "location_id": "BA-001"
skuStringSKU ( Stock Keeping Unit )
商品貨號
ruby "sku": "SL-GU-0001"
price
*Required
FloatProduct Price
原價格
ruby "price": 999
member_priceFloatMember Price
會員價
ruby "member_price": 900
quantity
*Required
IntegerProduct Quantity
商品數量
ruby "quantity": 100
imageStringLink of Images
圖片連結
-
*Only allows https
ruby "image": "https://the-allstars.com/blog/images/articl/ articl7.jpg"
price_saleFloatSale price
特價
"price_sale": 80
costFloatCost
成本價
"cost": 30
weightFloatWeight (kg)
重量 (公斤)
"weight": 1.2
gtinStringbarcode
商品條碼編號
"gtin": "1234567890"

Request Example

{
    "variant_options":[
        {
            "name_translations":{
                "zh-hant":"綠",
                "en":"green"
            },
            "type":"color"
        },
        {
            "name_translations":{
                "en":"L1",
                "zh-hant":"大1"
            },
            "type":"custom_1"
        }
    ],
    "location_id":"BA-001",
    "sku":"SL-GU-0001",
    "price":999,
    "member_price":900,
    "quantity":100,
    "image":"https://the-allstars.com/blog/images/articl/articl7.jpg",
    "price_sale":999,
    "cost":999,
    "weight":1.2,
    "gtin":"1234567890"
}

Response Example

Also same with Get Product

{
    "id": "5d5baa89c34f740006ce1adc",
    "fields_translations": {
        "en": [
            "green",
            "L1",
          	"Long1"
        ],
        "zh-hant": [
            "綠",
            "大1",
            "長1"
        ]
    },
    "price": {
        "cents": 999,
        "currency_symbol": "NT$",
        "currency_iso": "TWD",
        "label": "NT$999",
        "dollars": 999.0
    },
    "price_sale": {
        "cents": 0,
        "currency_symbol": "NT$",
        "currency_iso": "TWD",
        "label": "",
        "dollars": 0.0
    },
    "member_price": {
        "cents": 900,
        "currency_symbol": "NT$",
        "currency_iso": "TWD",
        "label": "NT$900",
        "dollars": 900.0
    },
    "quantity": 100,
    "unlimited_quantity": null,
    "media": {},
    "sku": "SL-GU-0001",
    "location_id": "BA-001",
    "variant_option_ids": [
        "5d5baa896c20ca00293f7455",
        "5d5baa896c20ca00293f7456",
      	"5d5baa896c20ca00293f7457"
    ],
    "barcode": null,
    "gtin": "1234567890",
    "out_of_stock_orderable": false,
    "subscription_enabled": false,
    "subscription_period_duration": 30,
    "filter_tags": []
}