Shopify后端对个人用户购物车一无所知,它们只存在于浏览器域中。我的错误,后端了解购物车,但您无法通过REST API编辑它们。 Here's the Cart endpoint if you're interested in getting carts。
若要操纵用户的购物车,您需要使用店面中的Ajax API。具体来说,this call将产品添加到购物车:
http://store.myshopify.com/cart.add.js?quantity=2&id=30104012
返回的JSON看起来是这样的:
http://store.myshopify.com/cart.js
:
{
"handle": "amelia",
"line_price": 4000,
"requires_shipping": true,
"price": 2000,
"title": "amelia - medium",
"url": "/products/amelia",
"quantity": 2,
"id": 30104012,
"grams": 200,
"sku": "",
"vendor": "the candi factory",
"image": "http://static.shopify.com/s/files/1/0040/7092/products/2766315_da1b.png?1268045506",
"variant_id": 30104012
}
您可以使用following call拿到车本身这会得到你这个:
{
"items": [
{
"handle": "aquarius",
"line_price": 6000,
"requires_shipping": true,
"price": 2000,
"title": "aquarius - medium",
"url": "/products/aquarius",
"quantity": 3,
"id": 30104042,
"grams": 181,
"sku": "",
"vendor": "the candi factory",
"image": "http://static.shopify.com/s/files/1/0040/7092/products/aquarius_1.gif?1268045506",
"variant_id": 30104042
},
{
"handle": "amelia",
"line_price": 4000,
"requires_shipping": true,
"price": 2000,
"title": "amelia - medium",
"url": "/products/amelia",
"quantity": 2,
"id": 30104012,
"grams": 200,
"sku": "",
"vendor": "the candi factory",
"image": "http://static.shopify.com/s/files/1/0040/7092/products/2766315_da1b.png?1268045506",
"variant_id": 30104012
}
],
"requires_shipping": true,
"total_price": 10000,
"attributes": null,
"item_count": 5,
"note": null,
"total_weight": 947
}
谢谢大卫。完善。 – Boz 2012-02-10 18:00:30
您好,先生,有可能通过API将自定义添加到购物车吗?比如说,如果我想将自定义名称,自定义描述和自定义价格放入没有ID的购物车中?先生非常感谢您。 – 2014-11-17 02:21:49