4

Shopifyを使用してショップを管理することを考えています。APIを使用して製品をWebサイトに追加する必要があります。

http://api.shopify.com/

このAPI呼び出しで製品と在庫を取得できます:

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

しかし、それから私は「バスケットに追加」したいと思います-私はこれを行う方法をAPIドキュメントから見ることができません。バスケットに追加したら、バスケットの内容を取得して、次のようなものを表示できるようにします...

"2 items : £130 - checkout"

詳細な答えは必要ありません-正しい方向に向けてください-ありがとう。

4

1 に答える 1

8

Shopifyバックエンドは個々のユーザーカートについて何も知りません。それらはブラウザランドにのみ存在します。私の間違いですが、バックエンドはカートについて知っていますが、RESTAPIを介してカートを編集することはできません。カートの入手に興味がある場合は、カートのエンドポイントを次に示します

ユーザーのカートを操作するには、ストアフロントからAjaxAPIを使用する必要があります。具体的には、この呼び出しにより、カートに商品が追加されます。

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
}
于 2012-02-09T21:08:32.783 に答える