HomeGuidesAPI ReferenceChangelogDiscussions
HomeLog In
Guides

Update Product

PUT <<api_domain>>/v1/products/:id
To update information about existing products with open API
透過open API更新商品資訊。

note:

  • hide_price can only be updated via admin interface

More on updating product with images:

As there is a timeout limit for requesting this api endpoint, we advice not to upload too many large-sized images when creating product. Instead, it is recommended to consider to divide the payload and request Add Product Images by batch.

Request Parameters

curl -X PUT \
  '<<api_domain>>/v1/products' \
  -H 'Accept: application/json' \
  -H 'Authorization: Bearar {access_token}' \
  -H 'Content-Type: application/json' \
  -H 'User-Agent: shopline-test' \
  -d '{
  "title_translations": {
    "en": "I want to update product title",
    "zh-hant": "我想更新商品名稱",
    "zh-cn": "我想更新商品名称"
  }
}'
{
  "title_translations": {
    "en": "I want to update product title",
    "zh-hant": "我想更新商品名稱",
    "zh-cn": "我想更新商品名称"
  }
}
{
    "is_replace_variations" :true,
    "variant_options": [
      {
        "name_translations": {
          "en": "green",
          "zh-hant": "綠"
        },
        "type": "color",
        "key": "green"
      },
      {
        "name_translations": {
          "en": "yellow",
          "zh-hant": "黃"
        },
        "type": "color",
        "key": "yellow"
      },
      {
        "name_translations": {
          "en": "big",
          "zh-hant": "大"
        },
        "type": "size",
        "key": "big"
      }
    ],
    "variations": [
      {
        "key": ["green", "big"],
        "sku": "green_big",
        "price": 147,
        "price_sale": 123,
        "cost": 5
      },
        {
        "key": ["yellow", "big"],
        "sku": "yellow_big"
      }
    ]
  }
{
  "variations":[
    {
      "id":"5f2ba26e52081b00125d3ad8",
      "sku":"green_big",
      "price":140,
      "price_sale":123,
      "cost":5
    }
  ]
}
{
  "images":[
    "https://shophub.oss-cn-shenzhen.aliyuncs.com/test-user-images/2/1-1606209585629-41388.jpg",
    {
      "url":"https://shophub.oss-cn-shenzhen.aliyuncs.com/test-user-images/2/1-1606209585629-41388.jpg",
      "alt_translations":{
        "en":"Cat",
        "zh-hant":"貓"
      }
    },
    {
      "url":"https://shophub.oss-cn-shenzhen.aliyuncs.com/test-user-images/2/1-1606209585629-41388.jpg",
      "alt_translations":{
        "en":"Dog",
        "zh-hant":"狗"
      }
    }
  ],
  "detail_images":[
    "https://shophub.oss-cn-shenzhen.aliyuncs.com/test-user-images/2/1-1606209585629-41388.jpg",
    {
      "url":"https://shophub.oss-cn-shenzhen.aliyuncs.com/test-user-images/2/1-1606209585629-41388.jpg",
      "alt_translations":{
        "en":"Cat",
        "zh-hant":"貓"
      }
    },
    {
      "url":"https://shophub.oss-cn-shenzhen.aliyuncs.com/test-user-images/2/1-1606209585629-41388.jpg",
      "alt_translations":{
        "en":"Dog",
        "zh-hant":"狗"
      }
    }
  ]
}
id Required String Product ID
欲更新資訊的商品ID
unlimited_quantity Boolean quantity of the product will be ignored once set
商品無限數量
location_id string stock unit number
儲位編號
summary_translations object Product Summary
商品摘要
en, zh-hant, zh-cn, vi, ms, ja, th, id, de, fr
sku string stock keeping unit
商品貨號
category_ids Array of String e.g. 58c1362f01cda3329300004d
title_translations Object supported object keys includes include
en, zh-hant, zh-cn, vi, ms, ja, th, id, de, fr
for different language
description_translations Object supported object keys includes include
en, zh-hant, zh-cn, vi, ms, ja, th, id, de, fr
for different language
seo_title_translations Object used for SEO purpose
supported object keys includes include
en, zh-hant, zh-cn, vi, ms, ja, th, id, de, fr
for different language, can be empty value
seo_description_translations Object used for SEO description
supported object keys includes include
en, zh-hant, zh-cn, vi, ms, ja, th, id, de, fr
for different language, can be empty value
seo_keywords String keyword separated by comma, max 160 characters, can be empty value
link String The link of the product from shop, cannot be empty value
is_preorder Boolean Allow product to be pre-ordered
preorder_limit Integer Preorder Limit (set to -1 if it's unlimited quantity) 預購上限(-1表示無限)
preorder_note_translations Object used for pre-order translation
supported object keys includes include
en, zh-hant, zh-cn, vi, ms, ja, th, id, de, fr
for different language
is_reminder_active boolean remind merchant product out of stock
是否開啟商品缺貨提醒
default: false
show_custom_related_products boolean Whether Show Custom Related Products
是否顯示相關商品
default: false
related_product_ids array of string array of product ids merchant suggest that might relate to this product
*Rules:
1.If show_custom_related_products is true and related_product_ids is filled: Filled related products will be displayed to customers.
2.If show_custom_related_products is true and related_product_ids is not filled: No related products will be displayed to customers.
3.If show_custom_related_products is false: Automatically suggested related products will be displayed to customers.
weight float product weight in kg
tags array of string array of tags for helping to search products at the admin panel and be used to set up product-related coupon
標籤功能用作商品搜尋,並能為指定商品設置優惠券的用途。
blacklisted_delivery_option_ids array of string these delivery options shouldn't available for delivery when buyers select this product
blacklisted_payment_ids array of string these payment options shouldn't available for payment when buyers select this product
max_order_quantity integer set maximum quantity buyer can buy per purchase
status String active 上架, draft 下架, hidden 隱藏商品
is_replace_variations Boolean Is replacing variations?
是否更換全部規格?
*Default: false
variant_options Array of Objects Maximum 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 Note: 如需使用 custom_1, custom_2, custom_3 請同步使用 variant_custom_type_translations 欄位

key 會對應到 variations, key 必須唯一不可以重複, 為選填media_id 圖片庫id
"variant_options": [ { "name_translations": { "en": "green", "zh-hant": "綠" }, "type": "color", "key": "green" } ]
如需對相同 type 的 variant_option 開啟顯示選項圖片於商品頁面,需要將相同 type 的 variant_option 皆設定 "selector_enabled": true 並設定 media_id 同時需要將 is_replace_variations 設定爲 true
variant_custom_type_translations Array of Objects If variant_options is custom_1, custom_2 or custom_3, you can edit the custom type name.
如果 variant_options 有使用到 type custom_1, custom_2 or custom_3, 才需要編輯此欄位,可以對自訂欄位命名
e.g. "variant_custom_type_translations": [ {"name_translations": { "en": "Custom1", "zh-hant": "自訂1" }, "type": "custom_1"}]
variations Array of Objects When is_replace_variations is true
Set details for variations
為商品規格設定資訊
"variations": [ { "key": ["green", "big"], "sku": "green_big", "price": 147, "price_sale": 123, "cost": 5 } ]
variations Array of Objects Set details for variations
為商品規格設定資訊
"variations": [ { "id": "5f2ba26e52081b00125d3ad8", "sku": "green_big", "price": 140, "price_sale": 123, "cost": 5, "gtin": "12343465745445" } ]
schedule_publish_at DateTime This product will be automatically online at the time you set.
此商品會於您設定的時間自動上架,若您設定「過去」的時間將不會有作用。
e.g. 2021-04-30T10:00:00.000+00:00 UTC time
gtin String Barcode number
商品條碼
default_show_image_selector Boolean Show image selector on product details page 顯示選項圖片於商品頁面
default: false
需要設定is_replace_variations: true才會生效
available_start_time DateTime Selling start time in UTC
預設商品銷售開始時間
available_end_time DateTime Selling end time in UTC
預設商品銷售結束時間
images Array of Strings/Array of Objects Images of the product, cannot be empty value
tax_type String Tax type
國內稅項
"1": 應稅
"3": 免稅
Default: null
oversea_tax_type String Oversea tax type
海外稅項
"1": 應稅
"2": 零稅率-非經海關出口
"5": 零稅率-經海關出口
Default: null

Response

May refer to Get Product for the most updated data

{
    "id": "5bd16a4f16d18c000fc7f91f",
    "status": "active",
    "title_translations": {
        "en": "I want to update product title",
        "zh-hant": "我想更新商品名稱",
        "zh-cn": "我想更新商品名称"
    },
    "price": {
        "cents": 1000,
        "currency_symbol": "NT$",
        "currency_iso": "TWD",
        "label": "NT$1,000",
        "dollars": 1000
    },
    "price_sale": {
        "cents": 689,
        "currency_symbol": "NT$",
        "currency_iso": "TWD",
        "label": "NT$689",
        "dollars": 689
    },
    "lowest_price": {
        "cents": 689,
        "currency_symbol": "NT$",
        "currency_iso": "TWD",
        "label": "NT$689",
        "dollars": 689
    },
    "hide_price": false,
    "same_price": true,
    "cost": {
        "cents": 609,
        "currency_symbol": "NT$",
        "currency_iso": "TWD",
        "label": "NT$609",
        "dollars": 609
    },
    "is_preorder": false,
    "preorder_limit": -1,
    "preorder_note_translations": {
        "en": "Shipping starts April 20th, 1971, preorder NOW!",
        "zh-hant": "1971/04/20 開始出貨, 立即訂購!"
    },
    "weight": 123.99,
    "quantity": 87,
    "unlimited_quantity": false,
    "medias": [
        {
            "images": {
                "original": {
                    "width": 1600,
                    "height": 500,
                    "url": "https://img.shoplineapp.com/media/image_clips/5bd16a4e8bf5370011d95736/original.png?1540450894"
                },
                "thumb": {
                    "width": 1600,
                    "height": 500,
                    "url": "https://img.shoplineapp.com/media/image_clips/5bd16a4e8bf5370011d95736/original.png?1540450894"
                },
                "source": {
                    "width": 1600,
                    "height": 500,
                    "url": "https://img.shoplineapp.com/media/image_clips/5bd16a4e8bf5370011d95736/original.png?1540450894"
                },
                "landscape": {
                    "width": 1600,
                    "height": 500,
                    "url": "https://img.shoplineapp.com/media/image_clips/5bd16a4e8bf5370011d95736/original.png?1540450894"
                },
                "favicon_small": {
                    "width": 1600,
                    "height": 500,
                    "url": "https://img.shoplineapp.com/media/image_clips/5bd16a4e8bf5370011d95736/original.png?1540450894"
                },
                "favicon": {
                    "width": 1600,
                    "height": 500,
                    "url": "https://img.shoplineapp.com/media/image_clips/5bd16a4e8bf5370011d95736/original.png?1540450894"
                },
                "favicon_large": {
                    "width": 1600,
                    "height": 500,
                    "url": "https://img.shoplineapp.com/media/image_clips/5bd16a4e8bf5370011d95736/original.png?1540450894"
                },
                "transparent_thumb": {
                    "width": 1600,
                    "height": 500,
                    "url": "https://img.shoplineapp.com/media/image_clips/5bd16a4e8bf5370011d95736/original.png?1540450894"
                },
                "transparent_medium": {
                    "width": 1600,
                    "height": 500,
                    "url": "https://img.shoplineapp.com/media/image_clips/5bd16a4e8bf5370011d95736/original.png?1540450894"
                },
                "transparent_large": {
                    "width": 1600,
                    "height": 500,
                    "url": "https://img.shoplineapp.com/media/image_clips/5bd16a4e8bf5370011d95736/original.png?1540450894"
                },
                "transparent_xlarge": {
                    "width": 1600,
                    "height": 500,
                    "url": "https://img.shoplineapp.com/media/image_clips/5bd16a4e8bf5370011d95736/original.png?1540450894"
                }
            },
            "_id": "5bd16a4e8bf5370011d95736",
            "alt_translations": {}
        }
    ],
    "category_ids": [
        "5892b76f72fdc0fc2e023828"
    ],
    "sku": "sku_123345",
    "barcode": null,
    "field_titles": [
        {
            "key": "color",
            "label": "Color",
            "name_translations": {
                "en": "Color",
                "zh-hant": "顏色"
            }
        },
        {
            "key": "custom",
            "label": "Custom",
            "name_translations": {
                "en": "Custom1",
                "zh-hant": "自訂1"
            }
        }
    ],
    "variations": [
        {
            "id": "5bd16a4f16d18c000fc7f921",
            "preorder_limit": -1,
            "fields_translations": {
                "en": [
                    "green",
                    "L1"
                ],
                "zh-hant": [
                    "綠",
                    "大1"
                ]
            },
            "price": {
                "cents": 0,
                "currency_symbol": "NT$",
                "currency_iso": "TWD",
                "label": "",
                "dollars": 0
            },
            "price_sale": {
                "cents": 689,
                "currency_symbol": "NT$",
                "currency_iso": "TWD",
                "label": "NT$689",
                "dollars": 689
            },
            "quantity": 1,
            "unlimited_quantity": null,
            "media": {},
            "sku": null,
            "barcode": null
        },
        {
            "id": "5bd16a4f16d18c000fc7f922",
            "preorder_limit": -1,
            "fields_translations": {
                "en": [
                    "green",
                    "S1"
                ],
                "zh-hant": [
                    "綠",
                    "小1"
                ]
            },
            "price": {
                "cents": 0,
                "currency_symbol": "NT$",
                "currency_iso": "TWD",
                "label": "",
                "dollars": 0
            },
            "price_sale": {
                "cents": 689,
                "currency_symbol": "NT$",
                "currency_iso": "TWD",
                "label": "NT$689",
                "dollars": 689
            },
            "quantity": 1,
            "unlimited_quantity": null,
            "media": {},
            "sku": null,
            "barcode": null
        },
        {
            "id": "5bd16a4f16d18c000fc7f923",
            "preorder_limit": -1,
            "fields_translations": {
                "en": [
                    "Red",
                    "L1"
                ],
                "zh-hant": [
                    "紅",
                    "大1"
                ]
            },
            "price": {
                "cents": 0,
                "currency_symbol": "NT$",
                "currency_iso": "TWD",
                "label": "",
                "dollars": 0
            },
            "price_sale": {
                "cents": 689,
                "currency_symbol": "NT$",
                "currency_iso": "TWD",
                "label": "NT$689",
                "dollars": 689
            },
            "quantity": 1,
            "unlimited_quantity": null,
            "media": {},
            "sku": null,
            "barcode": null
        },
        {
            "id": "5bd16a4f16d18c000fc7f924",
            "preorder_limit": -1,
            "fields_translations": {
                "en": [
                    "Red",
                    "S1"
                ],
                "zh-hant": [
                    "紅",
                    "小1"
                ]
            },
            "price": {
                "cents": 0,
                "currency_symbol": "NT$",
                "currency_iso": "TWD",
                "label": "",
                "dollars": 0
            },
            "price_sale": {
                "cents": 689,
                "currency_symbol": "NT$",
                "currency_iso": "TWD",
                "label": "NT$689",
                "dollars": 689
            },
            "quantity": 1,
            "unlimited_quantity": null,
            "media": {},
            "sku": null,
            "barcode": null
        }
    ],
    "categories": [
        {
            "id": "5892b76f72fdc0fc2e023828",
            "name_translations": {
                "en": "Featured Products",
                "zh-hant": "精選商品"
            },
            "seo_title_translations": {},
            "seo_description_translations": {},
            "seo_keywords": null,
            "key": "featured_products",
            "status": "active"
        }
    ],
    "out_of_stock_orderable": false,
    "subscription_enabled": false,
    "subscription_period_duration": 30,
    "filter_tags": [],
    "tax_type": null,
    "oversea_tax_type" null
}

常見問題 FAQ

  1. 如何更新規格的名稱?

    variant_options 需要帶入所有規格才能更新

    example: 商品規格有「顏色」、「尺寸」,「顏色」規格有 (希望能改成黃綠);「尺寸」規格有 SML

    1. GET Product GET <<api_domain>>v1/products/:id?fields\[]=variant_options
    2. Update Product variant_options PUT <<api_domain>>/v1/products/:id
      1. body parameters 需要將所有規格黃綠(原本是)、 SML 帶入 body parameters,並直接調整 name_translations 中的規格名稱

    curl --request PUT \
         --url https://open.shopline.io/v1/products/id \
         --header 'accept: application/json' \
         --header 'authorization: Bearer {token} ' \
         --header 'content-type: application/json' \
         --data '
    {
      "is_replace_variations": false,
      "default_show_image_selector": false,
      "variant_options": [
        {
          "id": "66d3ee9dfd5646001c5cc280",
          "name_translations": {
            "zh-hant": "紅",
            "en": ""
          },
          "type": "color",
          "media": null,
          "index": 0
        },
        {
          "id": "66d3ee9dfd5646001c5cc282",
          "name_translations": {
            "zh-hant": "S",
            "en": ""
          },
          "type": "size",
          "media": null,
          "index": 1
        },
        {
          "id": "66d3ee9dfd5646001c5cc283",
          "name_translations": {
            "zh-hant": "M",
            "en": ""
          },
          "type": "size",
          "media": null,
          "index": 1
        },
        {
          "id": "66d3ee9dfd5646001c5cc284",
          "name_translations": {
            "zh-hant": "L",
            "en": ""
          },
          "type": "size",
          "media": null,
          "index": 1
        },
        {
          "id": "66d3ee9dfd5646001c5cc281",
          "name_translations": {
            "zh-hant": "黃綠", // 欲調整的名稱
            "en": ""
          },
          "type": "color",
          "media": null,
          "index": 0
        }
      ]
    }'