Shopify API-添加到购物篮


Shopify API - add to basket

我正在考虑使用Shopify来管理我的商店。我需要将产品添加到API网站。

http://api.shopify.com/

我可以通过这个API调用获得产品和库存:

http://api.shopify.com/product.html#index

但是,我想"添加到篮子"-我无法从API文档中看到如何做到这一点。一旦添加到篮子中,我想得到篮子里的东西,这样我就可以显示这样的东西。。。

"2 items : £130 - checkout"

我不需要详细的答案,只要给我指明正确的方向就可以了,谢谢。

Shopify后端对个人用户购物车一无所知,它们只存在于浏览器领域我的错误是,后端确实知道推车,但您不能通过REST API编辑它们。如果您有兴趣获得购物车,下面是购物车端点。

操作用户的购物车,您需要从店面使用Ajax API。具体来说,这个调用将把产品添加到购物车中:

http://store.myshopify.com/cart.add.js?quantity=2&id=30104012

它返回如下所示的json:

{
    "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
}

您可以使用以下调用获取购物车本身:

http://store.myshopify.com/cart.js

这会让你得到这个:

{
    "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
}