PHPackages                             openy/commerce\_cart\_api - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [API Development](/categories/api)
4. /
5. openy/commerce\_cart\_api

ActiveDrupal-module[API Development](/categories/api)

openy/commerce\_cart\_api
=========================

Provides a RESTful interface to interact with carts in Drupal Commerce via a lightweight public API.

022.3k11JavaScript

Since Aug 11Pushed 2y ago1 watchersCompare

[ Source](https://github.com/ymcatwincities/commerce_cart_api)[ Packagist](https://packagist.org/packages/openy/commerce_cart_api)[ RSS](/packages/openy-commerce-cart-api/feed)WikiDiscussions 8.x-1.x Synced 1mo ago

READMEChangelogDependenciesVersions (1)Used By (1)

Commerce Cart API
=================

[](#commerce-cart-api)

Sandbox to provide a RESTful interface to interact with carts in Drupal Commerce via a lightweight public API.

How to test it out
------------------

[](#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)
-----------

[](#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
----

[](#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
-----

[](#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
------

[](#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.

###  Health Score

21

—

LowBetter than 18% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity25

Limited adoption so far

Community16

Small or concentrated contributor base

Maturity21

Early-stage or recently created project

 Bus Factor2

2 contributors hold 50%+ of commits

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

### Community

Maintainers

![](https://www.gravatar.com/avatar/bf41cdf9f0975a3cc5997aaaff41046eac88c85c7dbcd8410b8b09e35f55c11d?d=identicon)[danylevskyi](/maintainers/danylevskyi)

![](https://www.gravatar.com/avatar/1388b312dca2d4c24fb3474c71a6729b13b255860ff0188b0286013bc703bf5a?d=identicon)[podarok](/maintainers/podarok)

![](https://www.gravatar.com/avatar/4558114408c700ee4fe122cf32e229c67e2a72a8da55256930a02685612572fa?d=identicon)[Open-Y-Distro](/maintainers/Open-Y-Distro)

---

Top Contributors

[![jsacksick](https://avatars.githubusercontent.com/u/1007558?v=4)](https://github.com/jsacksick "jsacksick (3 commits)")[![mglaman](https://avatars.githubusercontent.com/u/3698644?v=4)](https://github.com/mglaman "mglaman (2 commits)")[![podarok](https://avatars.githubusercontent.com/u/563412?v=4)](https://github.com/podarok "podarok (2 commits)")

### Embed Badge

![Health badge](/badges/openy-commerce-cart-api/health.svg)

```
[![Health](https://phpackages.com/badges/openy-commerce-cart-api/health.svg)](https://phpackages.com/packages/openy-commerce-cart-api)
```

###  Alternatives

[stripe/stripe-php

Stripe PHP Library

4.0k143.3M480](/packages/stripe-stripe-php)[twilio/sdk

A PHP wrapper for Twilio's API

1.6k92.9M272](/packages/twilio-sdk)[facebook/php-business-sdk

PHP SDK for Facebook Business

90821.9M34](/packages/facebook-php-business-sdk)[meilisearch/meilisearch-php

PHP wrapper for the Meilisearch API

74513.7M114](/packages/meilisearch-meilisearch-php)[google/gax

Google API Core for PHP

265103.1M454](/packages/google-gax)[google/common-protos

Google API Common Protos for PHP

173103.7M50](/packages/google-common-protos)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
