aoepeople / aoe_cartapi
基于 Mage_Api2 的 Magento REST(ish) 购物车 API
Requires
- php: >= 5.4
- aoepeople/aoe_api2: *
- magento-hackathon/magento-composer-installer: *
Requires (Dev)
- ecomdev/ecomdev_phpunit: *
- phpmd/phpmd: *
- squizlabs/php_codesniffer: *
This package is not auto-updated.
Last update: 2022-09-17 07:25:32 UTC
README
Aoe_CartApi Magento 模块 
注意:此模块尚未准备好供公众消费。一旦准备好,我们将标记为 1.0.0 版本。
注意:以下“文档”只是规划此 API 时的笔记。
主要的购物车 API 端点
GET /api/rest/cart
返回当前前端 Magento 会话的购物车(报价)
{
"email": "fake@example.com",
"coupon_code": "",
"shipping_method": "flatrate_flatrate",
"qty": 5,
"totals": {
"subtotal": {
"title": "Subtotal",
"formatted": "$0.00",
"amount": 0,
"currency": "USD"
},
"shipping": {
"title": "Shipping",
"formatted": "$0.00",
"amount": 0,
"currency": "USD"
},
"discount": {
"title": "Discount"
"formatted": "$0.00",
"amount": 0,
"currency": "USD"
},
"tax": {
"title": "Tax",
"formatted": "$0.00",
"amount": 0,
"currency": "USD"
},
"grand_total": {
"title": "Grand Total",
"formatted": "$0.00",
"amount": 0,
"currency": "USD"
}
},
"messages": {
"error": [
"error message #1",
"error message #2"
]
"notice": [
"notice message #1",
"notice message #2"
]
"success": [
"success message #1",
"success message #2"
]
},
"has_error": false
}
支持的查询参数
- attrs
- 以逗号分隔的资源属性列表,您希望返回
- coupon_code
- shipping_method
- qty
- totals
- messages
- has_error
- 以逗号分隔的资源属性列表,您希望返回
- embed
- 以逗号分隔的子资源嵌入列表
- items
- billing_address
- shipping_address
- shipping_methods
- payment_methods (R)
- 以逗号分隔的子资源嵌入列表
POST /api/rest/cart
更新购物车资源的属性。使用 'embed' 查询参数将允许更新有限的子资源子集。
{
"coupon_code": "FREESTUFF"
}
支持的查询参数
- attrs
- 以逗号分隔的资源属性列表,您希望返回
- coupon_code
- shipping_method
- qty
- totals
- messages
- has_error
- 以逗号分隔的资源属性列表,您希望返回
- embed
- 以逗号分隔的子资源嵌入列表 (R) 和可能更新 (W)
- items (R)
- billing_address (R/W)
- shipping_address (R/W)
- shipping_methods (R)
- payment_methods (R)
- 以逗号分隔的子资源嵌入列表 (R) 和可能更新 (W)
DELETE /api/rest/cart
重置购物车及其所有子资源
GET /api/rest/cart/items
获取购物车项目集合。这将始终返回一个 JS 对象作为结果,即使集合为空。
{
"139303": {
"item_id": 139303,
"sku": "ABC123",
"name": "Thing #1",
"images": {
"normal": "<url>",
"small": "<url>",
"thumbnail": "<url>",
},
"children": []
"qty": 5,
"backorder_qty": 5,
"original_price": {
"formatted": "$0.00",
"amount": 0,
"currency": "USD"
},
"price": {
"formatted": "$0.00",
"amount": 0,
"currency": "USD"
},
"row_total": {
"formatted": "$0.00",
"amount": 0,
"currency": "USD"
},
"error_info": {},
"is_saleable": true
}
}
支持的查询参数
- attrs
- 以逗号分隔的资源属性列表,您希望返回
- item_id
- sku
- name
- images
- children
- qty
- backorder_qty
- original_price
- price
- row_total
- messages
- error_info
- is_saleable
- 以逗号分隔的资源属性列表,您希望返回
POST /api/rest/cart/items
添加产品到购物车。如果可能,将重用购物车中的现有项目。量属性是可选的,默认为单个单位。
{
"sku": "ABC123"
"qty": 1
}
您还可以使用 items 参数一次添加多个项目。如果您使用 items,则 sku 和 qty 将没有影响。
{
"items": [
{sku:"ABC123", qty:"2"},
{sku:"ABC456", qty:"4"}
}
}
支持的查询参数
- attrs
- 以逗号分隔的资源属性列表,您希望返回
- item_id
- sku
- name
- images
- children
- qty
- backorder_qty
- original_price
- price
- row_total
- messages
- error_info
- is_saleable
- 以逗号分隔的资源属性列表,您希望返回
DELETE /api/rest/cart/items
从购物车中删除所有项目
GET /api/rest/cart/items/:item_id
获取特定的购物车项目
{
"item_id": 139303,
"sku": "ABC123",
"name": "Thing #1",
"images": {
"normal": "<url>",
"small": "<url>",
"thumbnail": "<url>",
},
"children": []
"qty": 5,
"backorder_qty": 5,
"original_price": {
"formatted": "$0.00",
"amount": 0,
"currency": "USD"
},
"price": {
"formatted": "$0.00",
"amount": 0,
"currency": "USD"
},
"row_total": {
"formatted": "$0.00",
"amount": 0,
"currency": "USD"
},
"error_info": {},
"is_saleable": true
}
支持的查询参数
- attrs
- 以逗号分隔的资源属性列表,您希望返回
- item_id
- sku
- name
- images
- children
- qty
- backorder_qty
- original_price
- price
- row_total
- messages
- error_info
- is_saleable
- 以逗号分隔的资源属性列表,您希望返回
PUT/POST /api/rest/cart/items/:item_id
更新购物车中商品的数量
{
"qty": 4
}
支持的查询参数
- attrs
- 以逗号分隔的资源属性列表,您希望返回
- item_id
- sku
- name
- images
- children
- qty
- backorder_qty
- original_price
- price
- row_total
- messages
- error_info
- is_saleable
- 以逗号分隔的资源属性列表,您希望返回
DELETE /api/rest/cart/items/:item_id
从购物车中移除商品
GET /api/rest/cart/billing_address
返回与购物车关联的账单地址
{
"firstname": "John",
"middlename": "Quincy",
"lastname": "Public",
"prefix": "Mr.",
"suffix": "Jr.",
"company": "Acme Inc.",
"street":[
"Street 1",
"Street 2"
],
"city": "Burlingame",
"region": "California",
"postcode": "00000",
"country_id": "US",
"telephone": "000-000-0000",
"validation_errors":[
"Error Text",
"Error Text"
]
}
支持的查询参数
- attrs
- 以逗号分隔的资源属性列表,您希望返回
- firstname
- middlename
- lastname
- prefix
- suffix
- company
- street
- city
- region
- postcode
- country_id
- telephone
- formatted_html
- formatted_text
- validation_errors - 只有在响应 PUT/POST 请求时才会填充
- 以逗号分隔的资源属性列表,您希望返回
PUT/POST /api/rest/cart/billing_address
更新账单地址。所有属性都是可选的。
区域有一些“魔法”。您可以发送 Mage_Directory 数据库 ID、区域“代码”或区域“名称”。代码和名称将根据当前选定的国家进行查找。存储的区域要么是有效的区域名称(通过 ID/代码/名称查找),要么是发送的值。
{
"region": "FL"
}
支持的查询参数
- attrs
- 以逗号分隔的资源属性列表,您希望返回
- firstname
- middlename
- lastname
- prefix
- suffix
- company
- street
- city
- region
- postcode
- country_id
- telephone
- formatted_html
- formatted_text
- validation_errors - 只有在响应 PUT/POST 请求时才会填充
- 以逗号分隔的资源属性列表,您希望返回
DELETE /api/rest/cart/billing_address
重置账单地址
GET /api/rest/cart/shipping_address
返回与购物车关联的送货地址
{
"firstname": "John",
"middlename": "Quincy",
"lastname": "Public",
"prefix": "Mr.",
"suffix": "Jr.",
"company": "Acme Inc.",
"street":[
"Street 1",
"Street 2"
],
"city": "Burlingame",
"region": "California",
"postcode": "00000",
"country_id": "US",
"telephone": "000-000-0000",
"validation_errors":[
"Error Text",
"Error Text"
]
}
支持的查询参数
- attrs
- 以逗号分隔的资源属性列表,您希望返回
- firstname
- middlename
- lastname
- prefix
- suffix
- company
- street
- city
- region
- postcode
- country_id
- telephone
- formatted_html
- formatted_text
- validation_errors - 只有在响应 PUT/POST 请求时才会填充
- 以逗号分隔的资源属性列表,您希望返回
PUT/POST /api/rest/cart/shipping_address
更新送货地址。所有属性都是可选的。
区域有一些“魔法”。您可以发送 Mage_Directory 数据库 ID、区域“代码”或区域“名称”。代码和名称将根据当前选定的国家进行查找。存储的区域要么是有效的区域名称(通过 ID/代码/名称查找),要么是发送的值。
{
"region": "FL"
}
支持的查询参数
- attrs
- 以逗号分隔的资源属性列表,您希望返回
- firstname
- middlename
- lastname
- prefix
- suffix
- company
- street
- city
- region
- postcode
- country_id
- telephone
- formatted_html
- formatted_text
- validation_errors - 只有在响应 PUT/POST 请求时才会填充
- 以逗号分隔的资源属性列表,您希望返回
DELETE /api/rest/cart/shipping_address
重置送货地址
其他购物车相关资源
GET /api/rest/cart/crosssells
返回一组关联的交叉销售产品。**注意**:此集合会随着购物车数据的变化而变化。
{
"000-000": {
"sku": "000-000"
"name": "Dummy Product",
"description": "Dummy Product",
"short_description": "Dummy Product",
"url": "<url>",
"images": {
"normal": "<url>",
"small": "<url>",
"thumbnail": "<url>",
},
"is_in_stock": true,
"price": {
"formatted": "$0.00",
"amount": 0,
"currency": "USD"
},
"final_price": {
"formatted": "$0.00",
"amount": 0,
"currency": "USD"
},
"is_saleable": true,
"qty": 10000,
"min_sale_qty": null,
"max_sale_qty": 100
}
}
支持的查询参数
- attrs
- 以逗号分隔的资源属性列表,您希望返回
- sku
- name
- description
- short_description
- url
- images
- is_in_stock
- price
- final_price
- is_saleable
- qty
- min_sale_qty
- max_sale_qty
- 以逗号分隔的资源属性列表,您希望返回
GET /api/rest/cart/shipping_methods
返回一组可用的送货方式。**注意**:此集合会随着购物车数据的变化而变化。
[
{
"code": "flaterate_flaterate"
"carrier": "flaterate"
"carrier_title": "Flat Rate"
"method": "flaterate"
"method_title": "Flat Rate"
"description": "Flat rate shipping"
"price": {
"formatted": "$0.00"
"currency": "USD",
"amount": 0,
}
}
]
支持的查询参数
- attrs
- 以逗号分隔的资源属性列表,您希望返回
- code
- carrier
- carrier_title
- method
- method_title
- description
- price
- 以逗号分隔的资源属性列表,您希望返回
GET /api/rest/cart/payment_methods
返回一组可用的支付方式。**注意**:此集合会随着购物车数据的变化而变化,并且取决于商店的配置。
[
{
"code": "braintree",
"title": "Credit Card ",
"cc_types": {
"AE": "American Express",
"VI": "Visa",
"MC": "MasterCard"
}
},
{
"code": "checkmo",
"title": "Check / Money order",
"cc_types": null
}
]
注释
- 该模块目前正在为 PHP 5.4+ 编写,仅支持 Magento CE 1.8+。
- 当 PHP 5.4 达到 EOL 时,最低要求将更新以反映这一点。
- 如果/当 Magento CE 1.10 发布时,将取消对 Magento CE 1.8 的支持。