PHPackages                             daikazu/flexicart - 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. [Payment Processing](/categories/payments)
4. /
5. daikazu/flexicart

ActiveLibrary[Payment Processing](/categories/payments)

daikazu/flexicart
=================

A flexible shopping cart package for Laravel

v1.2.0(2mo ago)3104MITPHPPHP ^8.3CI passing

Since Jun 25Pushed 2mo ago1 watchersCompare

[ Source](https://github.com/daikazu/flexicart)[ Packagist](https://packagist.org/packages/daikazu/flexicart)[ Docs](https://github.com/daikazu/flexicart)[ GitHub Sponsors](https://github.com/Daikazu)[ RSS](/packages/daikazu-flexicart/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (4)Dependencies (34)Versions (5)Used By (0)

[  ![Logo for Flexi Cart](art/header-light.png)](https://mikewall.dev)FlexiCart
=========

[](#flexicart)

[![PHP Version Require](https://camo.githubusercontent.com/b9d54bc0423222fb01459d74612bac02cdedb8cf6d1bf959b177822cfe6b5496/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f7068702d762f6461696b617a752f666c657869636172743f7374796c653d666c61742d737175617265)](https://packagist.org/packages/daikazu/flexicart)[![Laravel Version](https://camo.githubusercontent.com/f9e09e79e46bf704f6ee19a83ee3e4b26851e30fbaace6522dd780c4c9181b9b/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4c61726176656c2d31312532422d7265643f7374796c653d666c61742d737175617265266c6f676f3d6c61726176656c)](https://laravel.com)[![Latest Version on Packagist](https://camo.githubusercontent.com/ec89fda8c1c5c002239877a996a2cdf9db65a430cd010d2a582163a58b394e1a/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6461696b617a752f666c657869636172742e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/daikazu/flexicart)[![GitHub Tests Action Status](https://camo.githubusercontent.com/203e88d8dcbbb37ef98d55e43e906ed1c34dd04c0797f6a8fe7610403a0c92c1/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f6461696b617a752f666c657869636172742f72756e2d74657374732e796d6c3f6272616e63683d6d61696e266c6162656c3d7465737473267374796c653d666c61742d737175617265)](https://github.com/daikazu/flexicart/actions?query=workflow%3Arun-tests+branch%3Amain)[![PHPStan](https://camo.githubusercontent.com/01f84d4b5cc923917f9a670578d7710d79f8a98187ae11a41e888ecacfa7a85b/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f6461696b617a752f666c657869636172742f7068707374616e2e796d6c3f6272616e63683d6d61696e266c6162656c3d5048505374616e263d666c61742d737175617265)](https://github.com/daikazu/flexicart/actions?query=workflow%3A%22Fix+PHP+code+style+issues%22+branch%3Amain)[![Total Downloads](https://camo.githubusercontent.com/0f04b56c4405ff2b896d6cab1ee88fa17bca4f2ae9cfb5425f4cfce83d0a126b/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6461696b617a752f666c657869636172742e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/daikazu/flexicart)[![GitHub forks](https://camo.githubusercontent.com/46e8dc76bf6380c1216510806176f539244f5672cca9d506d80f3f34de8dd147/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f666f726b732f6461696b617a752f666c657869636172743f7374796c653d666c61742d737175617265)](https://github.com/daikazu/flexicart/network)[![GitHub stars](https://camo.githubusercontent.com/c65f7f0df3c0256151d26ebf0acebc4a032337e61a6e0f9eff562bc9f5aa214b/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f73746172732f6461696b617a752f666c657869636172743f7374796c653d666c61742d737175617265)](https://github.com/daikazu/flexicart/stargazers)

A flexible shopping cart package for Laravel with support for session or database storage, conditional pricing, cart merging, rules engine, and custom product attributes.

Table of Contents
-----------------

[](#table-of-contents)

- [Features](#features)
- [Installation](#installation)
- [Basic Usage](#basic-usage)
    - [Adding Items](#adding-items-to-the-cart)
    - [Updating Items](#updating-items-in-the-cart)
    - [Removing Items](#removing-items-from-the-cart)
    - [Cart Totals](#getting-cart-content-and-calculations)
- [Conditions](#conditions)
    - [Understanding Conditions](#understanding-conditions)
    - [Adding Conditions](#adding-conditions)
    - [Removing Conditions](#removing-conditions)
    - [Non-Taxable Items](#marking-items-as-non-taxable)
- [Documentation](#documentation)
- [Testing](#testing)
- [Troubleshooting](#troubleshooting)
- [Changelog](#changelog)
- [Contributing](#contributing)
- [Security Vulnerabilities](#security-vulnerabilities)
- [Credits](#credits)
- [License](#license)

Features
--------

[](#features)

- **Flexible Storage**: Use session storage (default) or database storage
- **Cart Item Conditions**: Apply discounts, fees, or any adjustments to items
    - Percentage-based adjustments (e.g., 10% discount)
    - Fixed-amount adjustments (e.g., $5 off, $2 add-on fee)
    - Stack multiple conditions on the same item
- **Rules Engine**: Advanced promotional rules with cart context access
    - Buy X Get Y deals
    - Threshold-based discounts
    - Tiered volume discounts
    - Quantity-based rules
- **Cart Merging**: Flexible strategies for merging carts (guest to user, wishlist to cart)
- **Event System**: Hook into cart lifecycle for analytics, inventory, and integrations
- **Custom Product Attributes**: Store any item-specific attributes (color, size, etc.)
- **Global Cart Conditions**: Apply conditions to the cart subtotal or only to taxable items
- **Precise Price Handling**: Uses Brick/Money for accurate currency calculations
- **Taxable Item Support**: Mark specific items as taxable or non-taxable
- **Easy Integration**: Simple API with Laravel Facade

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

[](#installation)

### Requirements

[](#requirements)

- PHP 8.3 or higher
- Laravel 11.0 or higher
- Brick/Money package (automatically installed)

### Install the Package

[](#install-the-package)

```
composer require daikazu/flexicart
```

### Publish Configuration

[](#publish-configuration)

```
php artisan vendor:publish --tag="flexicart-config"
```

### Database Storage (Optional)

[](#database-storage-optional)

```
php artisan vendor:publish --tag="flexicart-migrations"
php artisan migrate
```

Then update your `.env` file:

```
CART_STORAGE=database
```

Basic Usage
-----------

[](#basic-usage)

### Adding Items to the Cart

[](#adding-items-to-the-cart)

```
use Daikazu\Flexicart\Facades\Cart;

// Add item as array
Cart::addItem([
    'id' => 1,
    'name' => 'Product Name',
    'price' => 29.99,
    'quantity' => 2,
    'attributes' => [
        'color' => 'red',
        'size' => 'large'
    ]
]);

// Add multiple items at once
Cart::addItem([
    [
        'id' => 2,
        'name' => 'Another Product',
        'price' => 15.50,
        'quantity' => 1
    ],
    [
        'id' => 3,
        'name' => 'Third Product',
        'price' => 45.00,
        'quantity' => 3
    ]
]);
```

### Updating Items in the Cart

[](#updating-items-in-the-cart)

```
// Update quantity
Cart::updateItem('item_id', ['quantity' => 5]);

// Update attributes
Cart::updateItem('item_id', [
    'attributes' => [
        'color' => 'blue',
        'size' => 'medium'
    ]
]);

// Update multiple properties
Cart::updateItem('item_id', [
    'quantity' => 3,
    'price' => 25.99,
    'attributes' => ['color' => 'green']
]);
```

### Removing Items from the Cart

[](#removing-items-from-the-cart)

```
// Remove a specific item
Cart::removeItem('item_id');

// Clear all items from the cart
Cart::clear();

// Clear all items and conditions from cart
Cart::reset();
```

### Getting Cart Content and Calculations

[](#getting-cart-content-and-calculations)

```
// Get all items
$items = Cart::items();

// Get a specific item
$item = Cart::item('item_id');

// Get cart counts
$totalItems = Cart::count(); // Total quantity of all items
$uniqueItems = Cart::uniqueCount(); // Number of unique items

// Check if cart is empty
$isEmpty = Cart::isEmpty();

// Get cart totals
$subtotal = Cart::subtotal(); // Subtotal before conditions
$total = Cart::total(); // Final total after all conditions
$taxableSubtotal = Cart::getTaxableSubtotal(); // Subtotal of taxable items only
```

Conditions
----------

[](#conditions)

### Understanding Conditions

[](#understanding-conditions)

Conditions are adjustments that can be applied to cart items or the entire cart:

- **Percentage Conditions**: Apply percentage-based adjustments (e.g., 10% discount)
- **Fixed Conditions**: Apply fixed-amount adjustments (e.g., $5 off)
- **Tax Conditions**: Special conditions for tax calculations

Conditions can target:

- **Individual Items**: Applied to specific cart items
- **Cart Subtotal**: Applied to the entire cart subtotal
- **Taxable Items**: Applied only to items marked as taxable

### Adding Conditions

[](#adding-conditions)

```
use Daikazu\Flexicart\Conditions\Types\PercentageCondition;
use Daikazu\Flexicart\Conditions\Types\FixedCondition;
use Daikazu\Flexicart\Enums\ConditionTarget;

// Add a 10% discount to the cart
$discount = new PercentageCondition(
    name: '10% Off Sale',
    value: -10, // Negative for discount
    target: ConditionTarget::SUBTOTAL
);
Cart::addCondition($discount);

// Add a $5 shipping fee
$shipping = new FixedCondition(
    name: 'Shipping Fee',
    value: 5.00,
    target: ConditionTarget::SUBTOTAL
);
Cart::addCondition($shipping);

// Add condition to a specific item
$itemDiscount = new PercentageCondition(
    name: 'Item Discount',
    value: -20,
    target: ConditionTarget::ITEM
);
Cart::addItemCondition('item_id', $itemDiscount);
```

### Removing Conditions

[](#removing-conditions)

```
// Remove a specific condition from the cart
Cart::removeCondition('10% Off Sale');

// Remove a condition from a specific item
Cart::removeItemCondition('item_id', 'Item Discount');

// Clear all cart conditions
Cart::clearConditions();
```

### Marking Items as Non-Taxable

[](#marking-items-as-non-taxable)

```
// Add non-taxable item
Cart::addItem([
    'id' => 4,
    'name' => 'Non-taxable Service',
    'price' => 100.00,
    'quantity' => 1,
    'taxable' => false
]);

// Update existing item to be non-taxable
Cart::updateItem('item_id', ['taxable' => false]);
```

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

[](#documentation)

For detailed documentation on specific features, see the following guides:

GuideDescription[Configuration](docs/CONFIGURATION.md)Storage options, currency settings, cleanup, and all config options[Rules Engine](docs/RULES_ENGINE.md)Advanced promotional rules: Buy X Get Y, thresholds, tiered discounts[Cart Merging](docs/MERGING.md)Merge strategies for guest-to-user carts, wishlists, and cart recovery[Events](docs/EVENTS.md)Cart lifecycle events for analytics, inventory, and integrations[Working with Prices](docs/PRICES.md)Price object API, arithmetic operations, and formatting[Blade Templates](docs/BLADE.md)Examples for displaying cart data in Blade views[Extending FlexiCart](docs/EXTENDING.md)Custom conditions, storage drivers, models, and merge strategiesTesting
-------

[](#testing)

```
composer test
```

Troubleshooting
---------------

[](#troubleshooting)

### Common Issues

[](#common-issues)

**Cart data not persisting between requests**

- Ensure sessions are properly configured in your Laravel application
- If using database storage, verify migrations have been run
- Check that the `CART_STORAGE` environment variable is set correctly

**Price calculation errors**

- Verify that all price values are numeric
- Ensure currency codes are valid ISO codes

**Condition not applying correctly**

- Verify condition targets are set appropriately
- Check condition order values if multiple conditions exist
- Ensure condition values are properly signed (negative for discounts)

**Memory issues with large carts**

- Consider implementing cart item limits
- Don't use session storage due to cookie size limits
- Use database storage for better memory management
- Implement cart cleanup for old/abandoned carts

Changelog
---------

[](#changelog)

Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.

Future Roadmap
--------------

[](#future-roadmap)

- API endpoints

Contributing
------------

[](#contributing)

Please see [CONTRIBUTING](CONTRIBUTING.md) for details.

Security Vulnerabilities
------------------------

[](#security-vulnerabilities)

Please review [our security policy](../../security/policy) on how to report security vulnerabilities.

Credits
-------

[](#credits)

- [Mike Wall](https://github.com/daikazu)
- [All Contributors](../../contributors)

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

43

—

FairBetter than 91% of packages

Maintenance88

Actively maintained with recent releases

Popularity14

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity54

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

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 ~88 days

Total

4

Last Release

62d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/4039367?v=4)[Mike Wall](/maintainers/daikazu)[@daikazu](https://github.com/daikazu)

---

Top Contributors

[![daikazu](https://avatars.githubusercontent.com/u/4039367?v=4)](https://github.com/daikazu "daikazu (69 commits)")

---

Tags

laravel-packageshopping-cartphplaravellaravel-packagecarte-commerceshopping cartdaikazuflexicart

###  Code Quality

TestsPest

Static AnalysisPHPStan, Rector

Code StyleLaravel Pint

### Embed Badge

![Health badge](/badges/daikazu-flexicart/health.svg)

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

###  Alternatives

[amsgames/laravel-shop

Package set to provide shop or e-commerce functionality (such as CART, ORDERS, TRANSACTIONS and ITEMS) to Laravel for customizable builds.

4845.9k](/packages/amsgames-laravel-shop)[lukepolo/laracart

A simple cart for Laravel

583135.4k1](/packages/lukepolo-laracart)[musahmusah/laravel-multipayment-gateways

A Laravel Package that makes implementation of multiple payment Gateways endpoints and webhooks seamless

852.2k1](/packages/musahmusah-laravel-multipayment-gateways)[creagia/laravel-redsys

Laravel Redsys Payments Gateway

2013.6k](/packages/creagia-laravel-redsys)

PHPackages © 2026

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