HomeGuidesAPI ReferenceChangelogDiscussions
HomeLog In
Guides

Update Product

PUT /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_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: Showing related products automatically no matter related_product_ids is filled or not. 2.If show_custom_related_products is false and related_product_ids is not filled : Not showing related products. 3.If show_custom_related_products is false and related_product_ids is filled : Showing filled products.
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
lacklisted_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 Boolean or String active, draft, removed, hidden, true, false
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

key 會對應到 variations, key 必須唯一不可以重複, 為選填media_id 圖片庫id
"variant_options": [ { "name_translations": { "en": "green", "zh-hant": "綠" }, "type": "color", "key": "green" } ]
variant_custom_type_translations Array of Objects If variant_options is custom_1, custom_3 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
available_start_time DateTime Selling start time in UTC
預設商品銷售開始時間
available_end_time DateTime Selling end time in UTC
預設商品銷售結束時間
labels Object special text tag to promotional or limited-edition products, which can help to catch customers' attention
Product Promotion Label FAQ
en, zh-hant, zh-cn, vi, ms, ja, th, id, de, fr

to create, must include included_fields[]=labels in query string
is_excluded_promotion boolean determine if promotion should excluded for this item
taxable boolean determine if the product is taxable
images Array of Strings/Array of Objects Images of the product, cannot be empty value

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_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",
            "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",
            "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",
            "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",
            "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": []
}