开放 API
使用说明
获取授权
全部 API
- Shop
- Metafields
- Customer
- CustomerAddress
- Account
- Product
- ProductVariant
- ProductImage
- Theme
- Asset
- Country
- Province
- City
- District
- ScriptTag
- Order
- Shipment
- ShipmentSupplier
- Payment
- PaymentMethod
- Redirect
- Page
- Webhook
- Blog
- BlogAuthor
- CustomerLevel
- StoreFile
- Promotion
- Coupon
- Post
- AfterSale
ProductVariant
ProductVariant
ProductVariant 为 Product 的单品或SKU,包含了单品特定样式信息和价格、重量、体积等,一个 Product 可以包含多个 ProductVariant 。
ProductVariant 对象支持 Metafields。
ProductVariant 相关API
ProductVariant 相关属性
- id
Number 类型,ProductVariant 的唯一整型标识。{ "id" : 148002 }
- product_id
Number 类型,ProductVariant 所属 Product 的唯一整型标识。{ "product_id" : 10254}
- created_at
Datetime 类型,ProductVariant 的创建时间。{ "created_at" : "2014-02-15T15:12:21+08:00" }
- updated_at
Datetime 类型,ProductVariant 的上一次更新时间。{ "updated_at" : "2014-02-15T15:12:21+08:00" }
- barcode
String 类型,ProductVariant 的编号。{ "barcode" : "102356-1002" }
- compare_price
Price 类型,ProductVariant 的原价。{ "compare_price" : 100 }
- price
Price 类型,ProductVariant 的售价。{ "price" : 200}
- image_id
Number 类型,ProductVariant 被关联的 ProductImage 的 ID。{ "image_id" : 125680 }
- sale
Number 类型,ProductVariant 的销量。{ "sale" : 126 }
- stock
Number 类型,ProductVariant 的库存。{ "stock" : 302 }
- reward_point
Number 类型,ProductVariant 的赠送积分。{ "reward_point" : 0 }
- volume
Float 类型,ProductVariant 的体积(单位:立方米)。{ "volume" : 100 }
- weight
Float 类型,ProductVariant 的重量(单位:千克)。{ "weight" : 200 }
- option_1
String 类型,ProductVariant 的商品属性 1。{ "option_1" : "白色" }
- option_2
String 类型,ProductVariant 的商品属性 2。{ "option_2" : "S码" }
- option_3
String 类型,ProductVariant 的商品属性 3。{ "option_3" : "纯棉"}
- stock_type
String 类型,ProductVariant 库存为0时是否仍可以购买,默认为B,不可购买,可选值 A:可购买, B:不可购买。{ "stock_type" : "B"}
- alarm_num
Number 类型,ProductVariant 的警报值。{ "alarm_num" : "1"}
- is_alarmed
Boolean 类型,ProductVariant 是否开启库存警报, true:开启,false:不开启,默认为不开启。{ "is_alarmed" : true}
- phone_alarm
Boolean 类型,ProductVariant 是否开启短信库存警报, true:开启,false:不开启,默认为不开启。{ "phone_alarm" : true}
- email_alarm
Boolean 类型,ProductVariant 是否开启邮件库存警报, true:开启,false:不开启,默认为不开启。{ "email_alarm" : true}
- weixin_alarm
Boolean 类型,ProductVariant 是否开启微信库存警报, true:开启,false:不开启,默认为不开启。{ "weixin_alarm" : true}
GET /products/#{id}/variants
获取 Product 所有 ProductVariant
- fields
- 需要查询的字段
- 获取 Product 所有 ProductVariant
- GET /products/12032/variants
{ "variants": [ { "barcode": "", "compare_price": 0, "created_at": "2014-02-15T15:12:21+08:00", "id": 95721, "image_id": null, "option_1": "白", "option_2": "诡异1", "option_3": "2", "price": 10, "product_id": 12032, "sale": 152, "stock": 100, "updated_at":"2014-02-15T15:12:21+08:00", "volume": 2, "weight": 40 }, { "barcode": "", "compare_price": 0, "created_at": "2014-02-15T15:16:21+08:00", "id": 95720, "image_id": null, "option_1": "白", "option_2": "诡异1", "option_3": "1", "price": 10, "product_id": 12032, "sale": 102, "stock": 100, "updated_at": "2014-02-15T15:16:21+08:00", "volume": 1, "weight": 10 } ] }
GET /products/#{id}/variants/count
获取 Product 所有 ProductVariant 的数量
- 获取商品所有 ProductVariant 的数量
- GET /products/12032/variants/count
{ "count": 2 }
GET /products/#{id}/variants/#{id}
获取 Product 的单个 ProductVariant
- fields
- 需要查询的字段
- 获取 Product 的单个 ProductVariant
- GET /products/12032/variants/95721
{ "variant": [ { "barcode": "", "compare_price": 0, "created_at": "2014-02-15T15:12:21+08:00", "id": 95721, "image_id": null, "option_1": "白", "option_2": "诡异1", "option_3": "2", "price": 10, "product_id": 12032, "sale": 120, "stock": 90, "updated_at":"2014-02-15T15:12:21+08:00", "volume": 1, "weight": 40 } ] }
POST /products/#{id}/variants
创建 ProductVariant
- variant[stock]
- ProductVariant 的库存
- variant[price]
- ProductVariant 的售价
- variant[image_id]
- ProductVariant 的关联图片 ID
- variant[compare_price]
- ProductVariant 的原价
- variant[volume]
- ProductVariant 的体积
- variant[weight]
- ProductVariant 的重量
- variant[barcode]
- ProductVariant 的编号
- variant[option_1]
- ProductVariant 的商品属性1
- variant[option_2]
- ProductVariant 的商品属性2
- variant[option_3]
- ProductVariant 的商品属性3
- 创建 ProductVariant
- POST /products/12560/variants
{ "variant": { "option_1": "白", "option_2": "萝卜", "option_3": "XXL", "price": 10, "compare_price": 0, "stock": 9, "weight": 4, "volume": 1, "barcode": "", "image_id": null } }
{ "variant": { "barcode": "", "compare_price": 0, "created_at": null, "id": 96323, "image_id": null, "option_1": "白", "option_2": "萝卜", "option_3": "XXL", "price": 10, "product_id": 12560, "sale": 0, "stock": 9, "updated_at": null, "volume": 1, "weight": 4 } }
PUT /products/#{id}/variants/#{id}
更新 ProductVariant
- variant[stock]
- ProductVariant 的库存
- variant[price]
- ProductVariant 的售价
- variant[image_id]
- ProductVariant 的关联图片 ID
- variant[compare_price]
- ProductVariant 的原价
- variant[volume]
- ProductVariant 的体积
- variant[weight]
- ProductVariant 的重量
- variant[barcode]
- ProductVariant 的编号
- variant[option_1]
- ProductVariant的商品属性1
- variant[option_2]
- ProductVariant 的商品属性2
- variant[option_3]
- ProductVariant 的商品属性3
- 更新 ProductVariant
- PUT /products/12560/variants/156896
{ "variant": { "barcode": "IPSCCC0001", "compare_price": 1000, "image_id": 12588, "option_1": "白", "option_2": "萝卜", "option_3": "XXL", "price": 10, "stock": 9, "volume": 0, "weight": 4 } }
{ "variant": { "barcode": "IPSCCC0001", "compare_price": 1000, "created_at": null, "id": 156896, "image_id": 12588, "option_1": "白", "option_2": "萝卜", "option_3": "XXL", "price": 10, "product_id": 12560, "sale": 0, "stock": 9, "updated_at": "2015-03-24T16:40:04.182+08:00", "volume": 0, "weight": 4 } }
DELETE /products/#{id}/variants/#{id}
删除 ProductVariant
- 删除 ProductVariant
- DELETE /products/12560/variants/156896
{}