shopify api 授权php,php – Shopify API – 添加到购物篮

这篇博客介绍了Shopify平台中购物车的工作原理,强调了后端并不直接处理购物车,而是在浏览器端进行操作。通过AjaxAPI,特别是`cart.add.js`接口,可以实现对用户购物车的添加商品功能。示例展示了添加商品后的JSON响应数据,包括商品详情、价格、数量等信息。`cart.js`则用于获取购物车当前状态。博客内容对于理解和操作Shopify购物车系统至关重要。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

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:

{

"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

}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值