openy/commerce_cart_api
Composer 安装命令:
composer require openy/commerce_cart_api
包简介
Provides a RESTful interface to interact with carts in Drupal Commerce via a lightweight public API.
关键字:
README 文档
README
Sandbox to provide a RESTful interface to interact with carts in Drupal Commerce via a lightweight public API.
How to test it out
- Clone down this repository into your Drupal Commerce TESTING PROJECT
- Add
$settings['extension_discovery_scan_tests'] = TRUE;to your settings.php - Enable
commerce_cart_api - Enabled
commerce_cart_reactjs - Remove default cart block with
commerce_cart_reactjs - Cart form automatically swapped.
GET (carts)
curl 'http://localhost:32775/cart?_format=json' Example JSON response for above.
[ { "order_id": 2, "uuid": "be9cb309-2c77-4f85-9444-013c91ab9318", "order_number": null, "store_id": 1, "total_price": { "number": "403.97", "currency_code": "USD" }, "order_items": [ { "order_item_id": 9, "uuid": "dcaa6901-f799-4505-af4c-9d1db9a85bbb", "type": "physical_product_variation", "purchased_entity": 4, "title": "Drupal Commerce Hoodie - Green, Small", "quantity": "2.00", "unit_price": { "number": "52.00", "currency_code": "USD" }, "total_price": { "number": "104.00", "currency_code": "USD" } }, { "order_item_id": 21, "uuid": "3bb80d13-ec7d-4e69-af33-a2f014c5e284", "type": "physical_product_variation", "purchased_entity": 15, "title": "Pronto600 Instant Camera", "quantity": "3.00", "unit_price": { "number": "99.99", "currency_code": "USD" }, "total_price": { "number": "299.97", "currency_code": "USD" } } ] } ] POST
Example to add items to cart. Creates or carts or adds to existing. Optional: Add the "combine" property to the payload (TRUE by default). FALSE will create another order item, while TRUE will increment an existing item.
curl -X POST \ 'http://localhost:32775/cart/add?_format=json' \ -H 'Content-Type: application/json' \ -d '[{ "purchased_entity_type": "commerce_product_variation", "purchased_entity_id": "6", "quantity": "1", "combine": true }]'
Response
[ { "order_id": 7, "uuid": "d0e68a71-780d-422e-b951-5ffc980bd296", "order_number": null, "store_id": 1, "total_price": { "number": "174.00", "currency_code": "USD" }, "order_items": [ { "order_item_id": 26, "uuid": "ec920271-51f7-4869-8e8f-46bdd733ba58", "type": "physical_product_variation", "purchased_entity": 21, "title": "24\" x 36\" Hot Air Balloons", "quantity": "2.00", "unit_price": { "number": "35.00", "currency_code": "USD" }, "total_price": { "number": "70.00", "currency_code": "USD" } }, { "order_item_id": 27, "uuid": "ac0a2890-38ab-4332-8425-8df7f1458552", "type": "physical_product_variation", "purchased_entity": 6, "title": "Drupal Commerce Hoodie - Green, Large", "quantity": "2.00", "unit_price": { "number": "52.00", "currency_code": "USD" }, "total_price": { "number": "104.00", "currency_code": "USD" } } ] } ] PATCH
A JSON object of order item IDs whose values are objects that define the item's new quantity.
{ 3: {"quantity": 1}, 9: {"quantity": 2}, } curl 'http://localhost:32775/cart/1/items?_format=json' -X PATCH \ -H 'Content-Type: application/json' \ --data-binary '{"2":{"quantity":"1"},"3":{"quantity":"1.00"}}'
Response
{ "order_id": 2, "uuid": "be9cb309-2c77-4f85-9444-013c91ab9318", "order_number": null, "store_id": 1, "total_price": { "number": "303.98", "currency_code": "USD" }, "order_items": [ { "order_item_id": 9, "uuid": "dcaa6901-f799-4505-af4c-9d1db9a85bbb", "type": "physical_product_variation", "purchased_entity": 4, "title": "Drupal Commerce Hoodie - Green, Small", "quantity": "2.00", "unit_price": { "number": "52.00", "currency_code": "USD" }, "total_price": { "number": "104.00", "currency_code": "USD" } }, { "order_item_id": 21, "uuid": "3bb80d13-ec7d-4e69-af33-a2f014c5e284", "type": "physical_product_variation", "purchased_entity": 15, "title": "Pronto600 Instant Camera", "quantity": "2.00", "unit_price": { "number": "99.99", "currency_code": "USD" }, "total_price": { "number": "199.98", "currency_code": "USD" } } ] } DELETE
Removes an order item from the cart.
curl 'http://localhost:32775/cart/2/items/9?_format=json' -X DELETE Response
No body, just HTTP code.
openy/commerce_cart_api 适用场景与选型建议
openy/commerce_cart_api 是一款 基于 JavaScript 开发的 Composer 扩展包,目前已累计 21.75k 次下载、GitHub Stars 达 0, 最近一次更新时间为 2026 年 01 月 04 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「drupal」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 openy/commerce_cart_api 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 openy/commerce_cart_api 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 openy/commerce_cart_api 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Provides an add-on purchasable entity.
Drupal integration module for the Kalastatic prototyping and styleguide tool
Provides a base set of configuration and module dependencies for starting new Drupal projects.
This module extends Drupal Migrate framework.
Installs and configures the WissKI base environment with mandatory modules.
Tiny set of PHP text utility classes.
统计信息
- 总下载量: 21.75k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 19
- 依赖项目数: 1
- 推荐数: 0
其他信息
- 授权协议: GPL-2.0
- 更新时间: 2026-01-04