PHPackages                             vanthao03596/cartly - 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. vanthao03596/cartly

ActiveLibrary[Framework](/categories/framework)

vanthao03596/cartly
===================

A flexible, customizable shopping cart library for Laravel with dynamic pricing

v1.2.0(5mo ago)02MITPHPPHP ^8.1CI passing

Since Jan 15Pushed 5mo agoCompare

[ Source](https://github.com/vanthao03596/cartly)[ Packagist](https://packagist.org/packages/vanthao03596/cartly)[ RSS](/packages/vanthao03596-cartly/feed)WikiDiscussions main Synced today

READMEChangelog (6)Dependencies (8)Versions (7)Used By (0)

Cartly
======

[](#cartly)

A flexible, customizable shopping cart library for Laravel with dynamic pricing.

[![Latest Version on Packagist](https://camo.githubusercontent.com/c978fcf65c6e6ae0e4e40f33443c5486eef538160c12e2d10dfb069c3140143c/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f76616e7468616f30333539362f636172746c792e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/vanthao03596/cartly)[![Total Downloads](https://camo.githubusercontent.com/7242c5017f9071f204f85140a09cb1f48be6f8e357d4c348f78e530916978cbf/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f76616e7468616f30333539362f636172746c792e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/vanthao03596/cartly)[![License](https://camo.githubusercontent.com/5e06791142b2b741a970f6db17fa894dddad0dca3304e4e6a6380141a6f755d7/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f76616e7468616f30333539362f636172746c792e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/vanthao03596/cartly)

Features
--------

[](#features)

- **No Stored Prices** - All prices resolved at runtime via pluggable resolvers
- **Multiple Storage Drivers** - Session, Database, Cache, or custom implementations
- **Multiple Cart Instances** - Support cart, wishlist, compare, and custom instances
- **Flexible Conditions** - Tax, discounts, shipping, and custom fee modifiers
- **Event-Driven Architecture** - Hooks into every cart operation
- **Guest-to-User Cart Merging** - Seamlessly merge carts on user login
- **Comprehensive Testing Utilities** - Fake mode, assertions, and factories

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

[](#requirements)

- PHP 8.1+
- Laravel 10.0, 11.0 or 12.0

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

[](#installation)

```
composer require vanthao03596/cartly
```

The package uses Laravel's auto-discovery, so the service provider and facade are registered automatically.

### Publish Configuration

[](#publish-configuration)

```
php artisan vendor:publish --provider="Cart\CartServiceProvider" --tag="config"
```

### Database Driver Setup (Optional)

[](#database-driver-setup-optional)

If you want to use the database driver for persistent storage:

```
php artisan vendor:publish --provider="Cart\CartServiceProvider" --tag="migrations"
php artisan migrate
```

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

[](#quick-start)

### Basic Usage

[](#basic-usage)

```
use Cart\Cart;

// Add an item to cart
$item = Cart::add($product, quantity: 2);

// Add with options
$item = Cart::add($product, quantity: 1, options: ['size' => 'L', 'color' => 'blue']);

// Update quantity
Cart::update($item->rowId, 5);

// Remove item
Cart::remove($item->rowId);

// Get totals (in cents)
$subtotal = Cart::subtotal();  // 4999
$total = Cart::total();        // 5499 (with tax)

// Clear cart
Cart::clear();
```

### Using Buyable Models

[](#using-buyable-models)

Implement the `Buyable` and `Priceable` interfaces on your model:

```
use Cart\Contracts\Buyable;
use Cart\Contracts\Priceable;
use Cart\Traits\CanBeBought;

class Product extends Model implements Buyable, Priceable
{
    use CanBeBought;

    // The trait auto-detects price from common attributes:
    // price, sale_price, current_price, original_price, regular_price
}
```

Or implement the methods manually:

```
class Product extends Model implements Buyable, Priceable
{
    public function getBuyableIdentifier(): int|string
    {
        return $this->id;
    }

    public function getBuyableDescription(): string
    {
        return $this->name;
    }

    public function getBuyableType(): string
    {
        return static::class;
    }

    public function getBuyablePrice(?CartContext $context = null): int
    {
        return $this->price; // In cents
    }

    public function getBuyableOriginalPrice(): int
    {
        return $this->original_price ?? $this->price;
    }
}
```

### Multiple Instances

[](#multiple-instances)

```
// Work with wishlist
Cart::instance('wishlist')->add($product);
// Or use magic method
Cart::wishlist()->add($product);

// Move item between instances
Cart::moveToWishlist($rowId);
Cart::moveToCart($rowId);
```

### Conditions

[](#conditions)

```
use Cart\Conditions\TaxCondition;
use Cart\Conditions\DiscountCondition;

// Add 10% tax
Cart::condition(new TaxCondition('VAT', rate: 10));

// Add 15% discount
Cart::condition(new DiscountCondition('Summer Sale', value: 15, mode: 'percentage'));

// Add fixed discount
Cart::condition(new DiscountCondition('Coupon', value: 1000, mode: 'fixed')); // $10.00 off

// Get breakdown
$breakdown = Cart::getCalculationBreakdown();
```

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

[](#documentation)

For complete documentation, see the [docs](docs/index.md) folder:

- [Installation](docs/installation.md)
- [Configuration](docs/configuration.md)
- [Basic Usage](docs/usage/basic-usage.md)
- [Multiple Instances](docs/usage/multiple-instances.md)
- [Conditions](docs/usage/conditions.md)
- [API Reference](docs/api-reference/cart-facade.md)
- [Testing](docs/testing.md)
- [Architecture](docs/architecture/overview.md)

Testing
-------

[](#testing)

```
composer test
```

License
-------

[](#license)

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

###  Health Score

33

—

LowBetter than 72% of packages

Maintenance70

Regular maintenance activity

Popularity2

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity48

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

Total

6

Last Release

168d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/34786441?v=4)[Pham Thao](/maintainers/vanthao03596)[@vanthao03596](https://github.com/vanthao03596)

---

Top Contributors

[![vanthao03596](https://avatars.githubusercontent.com/u/34786441?v=4)](https://github.com/vanthao03596 "vanthao03596 (14 commits)")

---

Tags

laravelecommercecartshopping

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StyleLaravel Pint

### Embed Badge

![Health badge](/badges/vanthao03596-cartly/health.svg)

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

###  Alternatives

[psalm/plugin-laravel

Psalm plugin for Laravel

3355.3M346](/packages/psalm-plugin-laravel)[laravel/pulse

Laravel Pulse is a real-time application performance monitoring tool and dashboard for your Laravel application.

1.7k15.1M132](/packages/laravel-pulse)[laravel/ai

The official AI SDK for Laravel.

1.0k3.2M194](/packages/laravel-ai)[laravel/cashier

Laravel Cashier provides an expressive, fluent interface to Stripe's subscription billing services.

2.6k29.9M146](/packages/laravel-cashier)[laravel/scout

Laravel Scout provides a driver based solution to searching your Eloquent models.

1.7k55.0M616](/packages/laravel-scout)[roots/acorn

Framework for Roots WordPress projects built with Laravel components.

9762.4M131](/packages/roots-acorn)

PHPackages © 2026

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