這兩個頁面應該幫助你:
Adding to the Cart from a remote website
我不知道自己在做什麼添加到購物車,現在,但是這是「正確」的方式做到這一點。看到你已經有了這個工作,我不會太擔心。
爲了讓車,你應該使用AJAX API。該API允許您爲當前用戶提供購物車,而無需使用您鏈接的REST版本。那個設計用於做更重的舉重(例如獲得當前所有的活動推車)。 AJAX版本非常簡單,專爲前端使用而設計。簡單而言,只需撥打
http://[the-shop].myshopify.com/cart.js
,你會回來的車的內容爲JSON當前會話。它會是這個樣子:
{
"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
}
感謝您的回覆。過去一週我們一直在研究這個問題,我們遇到的問題是將shopify的信息拖到我們自己的網站上,這似乎並不奏效。 Shopify中是否有安全功能可防止將該信息(購物車中的物品)拉到遠程站點? – flinx777 2012-05-07 19:00:39
沒有。您可能遇到[相同來源策略](http://en.wikipedia.org/wiki/Same_origin_policy)問題,但數據應該可用。 – 2012-05-08 03:28:11