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
}