PHPackages                             aiarmada/cart - 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. [Framework](/categories/framework)
4. /
5. aiarmada/cart

ActiveLibrary[Framework](/categories/framework)

aiarmada/cart
=============

A comprehensive commerce ecosystem for Laravel with cart, payments, vouchers, shipping, and inventory management.

v0.1.34(2mo ago)01474MITPHPPHP ^8.4

Since May 21Pushed 1mo agoCompare

[ Source](https://github.com/AIArmada/cart)[ Packagist](https://packagist.org/packages/aiarmada/cart)[ Docs](https://github.com/aiarmada/commerce)[ RSS](/packages/aiarmada-cart/feed)WikiDiscussions main Synced 1w ago

READMEChangelogDependencies (13)Versions (69)Used By (4)

AIArmada Cart
=============

[](#aiarmada-cart)

A modern, production-grade shopping cart engine for Laravel 12 applications.

Features
--------

[](#features)

- **Database Storage** – Built-in persistence with optimistic locking and owner scoping
- **Multi-Instance Carts** – Support multiple cart buckets per user (cart, wishlist, compare)
- **Precision Calculations** – Money objects via `akaunting/money` for accurate financial math
- **Flexible Conditions** – Discounts, taxes, fees, and shipping with targeted application
- **Payment Gateway Ready** – Implements `CheckoutableInterface` for any payment provider
- **Concurrency Safe** – Optimistic locking prevents race conditions
- **Event-Driven** – Hooks for logging, analytics, and business logic

Requirements
------------

[](#requirements)

- PHP 8.4+
- Laravel 12.x

Installation
------------

[](#installation)

```
composer require aiarmada/cart
```

Laravel auto-discovers the service provider. To publish configuration:

```
php artisan vendor:publish --tag=cart-config
```

For database storage, publish and run migrations:

```
php artisan vendor:publish --tag=cart-migrations
php artisan migrate
```

Quick Start
-----------

[](#quick-start)

```
use AIArmada\Cart\Facades\Cart;

// Add items
Cart::add('laptop-001', 'MacBook Pro 16"', 2499.00, 1, [
    'sku' => 'MBP16-2024',
    'color' => 'Space Gray',
]);

// Get totals
echo Cart::count();           // Total quantity
echo Cart::total()->format(); // "$2,499.00"

// Apply conditions
Cart::addDiscount('promo', '10%');
Cart::addTax('vat', '8%');
Cart::addShipping('standard', '15.00');

// Work with items
$item = Cart::get('laptop-001');
Cart::update('laptop-001', ['quantity' => 2]);
Cart::remove('laptop-001');

// Multiple instances
Cart::instance('wishlist')->add('monitor-001', 'Display', 599.00);
```

Storage
-------

[](#storage)

The package ships with `DatabaseStorage` only. If you need a different backend, bind your own `StorageInterface` implementation in the service container.

```
use AIArmada\Cart\Storage\StorageInterface;

$this->app->bind(StorageInterface::class, function ($app): StorageInterface {
    return new App\Cart\Storage\CustomStorage(...);
});
```

Conditions
----------

[](#conditions)

Apply discounts, taxes, and fees at different calculation phases:

```
use AIArmada\Cart\Conditions\CartCondition;
use AIArmada\Cart\Conditions\TargetPresets;

// Percentage discount
Cart::addDiscount('summer-sale', '20%');

// Fixed amount
Cart::addDiscount('welcome', '-10.00');

// Custom condition
$condition = new CartCondition(
    name: 'vip-discount',
    type: 'discount',
    target: TargetPresets::cartSubtotal(),
    value: '-15%',
    rules: [fn($cart) => auth()->user()?->isVip()],
);
Cart::addCondition($condition);
```

Payment Integration
-------------------

[](#payment-integration)

Cart implements `CheckoutableInterface` for seamless payment gateway integration:

```
use AIArmada\Chip\Gateways\ChipGateway;

$gateway = app(ChipGateway::class);
$cart = app(\AIArmada\Cart\Cart::class);

$payment = $gateway->createPayment($cart, $customer, [
    'success_url' => route('checkout.success'),
    'failure_url' => route('checkout.failed'),
]);

return redirect($payment->getCheckoutUrl());
```

Guest to User Migration
-----------------------

[](#guest-to-user-migration)

Automatically migrate guest carts when users log in:

```
// config/cart.php
'migration' => [
    'auto_migrate_on_login' => true,
    'merge_strategy' => 'add_quantities', // or keep_highest_quantity, keep_user_cart
],
```

Events
------

[](#events)

Listen to cart lifecycle events:

- `CartCreated`, `CartCleared`, `CartDestroyed`, `CartMerged`
- `ItemAdded`, `ItemUpdated`, `ItemRemoved`
- `CartConditionAdded`, `CartConditionRemoved`
- `ItemConditionAdded`, `ItemConditionRemoved`
- `MetadataAdded`, `MetadataRemoved`, `MetadataBatchAdded`, `MetadataCleared`

```
use AIArmada\Cart\Events\ItemAdded;

Event::listen(ItemAdded::class, function ($event) {
    Log::info('Item added', ['item' => $event->cartItem->id]);
});
```

JSON Column Type
----------------

[](#json-column-type)

Migrations default to `json` columns. For PostgreSQL with `jsonb`:

```
COMMERCE_JSON_COLUMN_TYPE=jsonb
# or per-package
CART_JSON_COLUMN_TYPE=jsonb
```

Documentation
-------------

[](#documentation)

Full documentation is available in the [`docs/`](docs/) directory:

- [Overview](docs/01-overview.md)
- [Installation](docs/02-installation.md)
- [Configuration](docs/03-configuration.md)
- [Usage](docs/04-usage.md)
- [Storage](docs/08-storage.md)

Development
-----------

[](#development)

```
composer install
vendor/bin/pest
vendor/bin/pint --dirty
```

Testing
-------

[](#testing)

```
vendor/bin/pest tests/src/Cart --parallel
```

License
-------

[](#license)

MIT License. See [LICENSE](../../LICENSE).

###  Health Score

45

—

FairBetter than 91% of packages

Maintenance89

Actively maintained with recent releases

Popularity11

Limited adoption so far

Community16

Small or concentrated contributor base

Maturity56

Maturing project, gaining track record

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.

###  Release Activity

Cadence

Every ~3 days

Total

68

Last Release

82d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/1634949?v=4)[Saiffil Fariz](/maintainers/sairiz)[@sairiz](https://github.com/sairiz)

### Embed Badge

![Health badge](/badges/aiarmada-cart/health.svg)

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

###  Alternatives

[microweber/microweber

New generation CMS with drag and drop

3.4k14.0k1](/packages/microweber-microweber)

PHPackages © 2026

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