daikazu/flexicart

A Flexible Shopping Cart for Laravel

Everything you need to build powerful e-commerce experiences. Conditions, rules engine, precise pricing, and seamless Laravel integration.

Flexible Storage

Choose between session storage (default) or database storage. Perfect for guest carts and persistent user carts.

// config/flexicart.php
'storage' => env('CART_STORAGE', 'session'),

Powerful Conditions

Apply percentage or fixed-amount conditions to items or the entire cart. Stack multiple conditions with custom ordering.

$discount = new PercentageCondition(
    name: '10% Off',
    value: -10,
    target: ConditionTarget::SUBTOTAL
);
Cart::addCondition($discount);

Smart Rules Engine

Context-aware promotional rules: Buy X Get Y, threshold discounts, tiered volume discounts, and more.

$rule = new BuyXGetYRule(
    name: 'Buy 2 Get 1 Free',
    buyQuantity: 2,
    getQuantity: 1,
    getDiscount: 100.0
);
Cart::addRule($rule);

Brick/Money Integration

Precise currency handling with no floating-point errors.

Custom Attributes

Store color, size, or any custom data with cart items.

Taxable Support

Mark items as taxable or non-taxable for proper tax calculations.

Event System

Hook into cart actions for analytics and inventory management.

Cart Merging

Merge guest carts with user carts using flexible strategies.

Item Conditions

Apply discounts or fees to individual cart items.

Simple API

Clean, expressive API with Laravel Facade support.

Laravel Native

Built specifically for Laravel 11+ with PHP 8.3+ support.

Quick Start

Basic Cart Operations

use Daikazu\Flexicart\Facades\Cart;

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

// Get cart totals
$subtotal = Cart::subtotal();
$total = Cart::total();
$count = Cart::count();

Conditions & Rules

use Daikazu\Flexicart\Conditions\Types\*;
use Daikazu\Flexicart\Conditions\Rules\*;

// Add a percentage discount
Cart::addCondition(new PercentageCondition(
    name: 'Holiday Sale',
    value: -15,
    target: ConditionTarget::SUBTOTAL
));

// Add a threshold rule
Cart::addRule(new ThresholdRule(
    name: 'Spend $100 Save 10%',
    minSubtotal: 100.00,
    discount: -10.0,
    discountType: ConditionType::PERCENTAGE
));

Ready to get started?

Install FlexiCart in your Laravel project and build powerful e-commerce experiences in minutes.

composer require daikazu/flexicart
View on GitHub

Shopping Cart

0 items

Your cart is empty

Add some products to get started!