PHPackages                             cyvelnet/laravel-easycart - 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. [Utility &amp; Helpers](/categories/utility)
4. /
5. cyvelnet/laravel-easycart

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

cyvelnet/laravel-easycart
=========================

A simple &amp; easy to use yet powerful laravel cart solution

v1.0.0(4y ago)396MITPHPPHP ^5.6|^7.0|^8.0

Since Oct 16Pushed 4y ago1 watchersCompare

[ Source](https://github.com/Cyvelnet/laravel-easycart)[ Packagist](https://packagist.org/packages/cyvelnet/laravel-easycart)[ RSS](/packages/cyvelnet-laravel-easycart/feed)WikiDiscussions master Synced today

READMEChangelog (9)Dependencies (4)Versions (9)Used By (0)

Laravel EasyCart
================

[](#laravel-easycart)

[![StyleCI](https://camo.githubusercontent.com/76a3fe76a9fc75bf531f6afd6fc9ce956f534b198268a6de0db95e4da9565629/68747470733a2f2f7374796c6563692e696f2f7265706f732f39323131313838342f736869656c643f6272616e63683d6d6173746572)](https://styleci.io/repos/92111884)[![Build Status](https://camo.githubusercontent.com/ca430627436345d0693a20093d9f8abb723baea485f26729676ada18895421bb/68747470733a2f2f7472617669732d63692e6f72672f437976656c6e65742f6c61726176656c2d65617379636172742e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/Cyvelnet/laravel-easycart)[![Total Downloads](https://camo.githubusercontent.com/83b593774b5c8f530859b6f9c4edf774eb03ab628c3143db8de8cdecad9cc51f/68747470733a2f2f706f7365722e707567782e6f72672f637976656c6e65742f6c61726176656c2d65617379636172742f646f776e6c6f616473)](https://packagist.org/packages/cyvelnet/laravel-easycart)[![Latest Stable Version](https://camo.githubusercontent.com/92dbc25e84a552c7884f0ae8588a6f2454711282bf642dce9f95a4cb1872cd23/68747470733a2f2f706f7365722e707567782e6f72672f637976656c6e65742f6c61726176656c2d65617379636172742f762f737461626c65)](https://packagist.org/packages/cyvelnet/laravel-easycart)[![Latest Unstable Version](https://camo.githubusercontent.com/65c45dcab2de0ba283fc68f8e10db8fd2ea9db6fdb073ff5e1c9a65968e80292/68747470733a2f2f706f7365722e707567782e6f72672f637976656c6e65742f6c61726176656c2d65617379636172742f762f756e737461626c65)](https://packagist.org/packages/cyvelnet/laravel-easycart)[![License](https://camo.githubusercontent.com/e2338313c93e5603dd3a17e7d05be2f06cf11bb431e1c67696408e185f18d480/68747470733a2f2f706f7365722e707567782e6f72672f637976656c6e65742f6c61726176656c2d65617379636172742f6c6963656e7365)](https://packagist.org/packages/cyvelnet/laravel-easycart)

This project is still under development, it is far from ready for production.

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

[](#installation)

Require this package with composer using the following command:

```
composer require cyvelnet/laravel-easycart
```

After updating composer, add the ServiceProvider to the providers array in config/app.php

```
Cyvelnet\EasyCart\EasyCartServiceProvider::class,
```

and register Facade And optionally add a new line to the `aliases` array:

```
'EasyCart' => Cyvelnet\EasyCart\Facades\EasyCart::class,

```

- [Usage](#usage)
- [Filtering](#filtering)
- [Condition](#condition)
- [Instances](#instances)

Usage
-----

[](#usage)

### EasyCart::add()

[](#easycartadd)

Add new product or update quantity on existing cart item

```
// Add product to cart
EasyCart::add($id, $name, $price, $qty);

// Add product to cart with attributes & weight
EasyCart::add($id, $name, $price, $qty, $attributes = [], $weight);

// Add multiple products
EasyCart::add([
    [
        'id' => '1'
        'name' => 'Product 1'
        'price' => '199.99'
        'qty' => '1',
        'attributes' => ['color' => 'red'],
        'weight' => 0.5
    ],
    [
        'id' => '2'
        'name' => 'Product 2'
        'price' => '299.99'
        'qty' => '1'
    ]
]);
```

### EasyCart::update()

[](#easycartupdate)

Update cart item

- `An unique rowId is assigned to each cart item, use `getRowId()`on cart item to retrieves rowId`\*

```
// update qty
EasyCart::update($rowId, $qty);

// update other
EasyCart::update($rowId, [

    'attributes' => ['color' => 'green'],
    'qty' => 2,
    'price' => 399.99

]);
```

### EasyCart::remove()

[](#easycartremove)

Remove an item from cart

```
EasyCart::remove($rowId);
```

### EasyCart::get()

[](#easycartget)

Get a row by rowId

```
EasyCart::get($rowId);
```

### EasyCart::destroy()

[](#easycartdestroy)

Wipe cart completely

```
EasyCart::destroy();
```

### EasyCart::qty()

[](#easycartqty)

Get the total number of quantity in cart.

```
EasyCart::qty();
```

### EasyCart::subtotal()

[](#easycartsubtotal)

Get the cart subtotal before a condition value is being added, use `EasyCart::total()` to retrieves the final price

```
EasyCart::subtotal();
```

### EasyCart::total()

[](#easycarttotal)

Get the cart total with condition values calculated

```
EasyCart::total();
```

### EasyCart::items()

[](#easycartitems)

Get the cart items `EasyCart::content() is an aliase to EasyCart::items()`, `Cyvelnet\EasyCart\Collections\CartItemCollection` instance is return

```
EasyCart::items()
```

### EasyCart::weight()

[](#easycartweight)

Get the cart total weight

```
EasyCart::weight()
```

Filtering
---------

[](#filtering)

### EasyCart::find()

[](#easycartfind)

Find a cart item by product id, a `Cyvelnet\EasyCart\CartItem` instance is return

```
EasyCart::find($id);
```

### EasyCart::findByIds()

[](#easycartfindbyids)

Find a cart item by an array of ids, a `Cyvelnet\EasyCart\Collections\CartItemCollection` instance is return

```
EasyCart::findByIds($ids = []);
```

Condition
---------

[](#condition)

EasyCart support condition, which is essential to ECommerces application, either provides discount or add additional prices are supported.

### EasyCart::condition()

[](#easycartcondition)

Adding a condition is simple, just instantiate a Cyvelnet\\EasyCart\\CartCondition object and you are ready to go.

```
// Add a 50% discount to cart

$fiftyPercentDiscount = new CartCondition($name = '$50 Off', $value = '-50') // you have to use a - (minus sign) to indicate a discount is expected

EasyCart::condition($fiftyPercentDiscount);
```

Sometimes you want to only give an discount to only to a selected range of products instead of apply to the whole cart, it is easy

```
$fiftyPercentDiscount = new CartCondition($name = '$50 Off', $value = '-50');
$fiftyPercentDiscount->onProduct([1,2,3,4]);

EasyCart::condition($fiftyPercentDiscount);
```

Life is not always easy, what if you need to give an discount of 20% but with a maximum up to $50 ?

```
$fiftyPercentDiscount = new CartCondition($name = '20% Off', $value = '-20');
$fiftyPercentDiscount->maxAt(50);

EasyCart::condition($fiftyPercentDiscount);
```

### EasyCart::removeConditionByType()

[](#easycartremoveconditionbytype)

Remove condition by type

```
EasyCart::removeConditionByType($type);
```

### EasyCart::removeConditionByName()

[](#easycartremoveconditionbyname)

Remove condition by name

```
EasyCart::removeConditionByName($name);
```

Instances
---------

[](#instances)

EasyCart support multiple instances, no extra configuration is needed, just point it to instance and it works the same as normal

```
EasyCart::instance('wishlist')->add($id, $name, $price, $qty);
EasyCart::instance('wishlist')->destroy();
```

### Instances Expiration

[](#instances-expiration)

Sometimes a cart expiration is needed, maybe for reservation, or other usage, this is handful in EasyCart

```
// create a new instances with 15 minutes expiration
EasyCart::instance('reservation', \Carbon::now()->addMinutes(15));
```

To verify whether a cart is expired, use `EasyCart::isExpired()`

```
// check if a cart is expired
EasyCart::instance('reservation')->isExpired();
```

Since you may expire a cart, you might want to make a countdown too

```
EasyCart::instance('reservation')->expirationTimestamp();
```

###  Health Score

32

—

LowBetter than 69% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity13

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity73

Established project with proven stability

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

Recently: every ~334 days

Total

8

Last Release

1581d ago

Major Versions

v0.6.1 → v1.0.02022-03-02

PHP version history (2 changes)v0.5.1PHP ^5.6|^7.0

v0.6.1PHP ^5.6|^7.0|^8.0

### Community

Maintainers

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

---

Top Contributors

[![Cyvelnet](https://avatars.githubusercontent.com/u/11516087?v=4)](https://github.com/Cyvelnet "Cyvelnet (49 commits)")

---

Tags

shopping cartLaravel carteasycart

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/cyvelnet-laravel-easycart/health.svg)

```
[![Health](https://phpackages.com/badges/cyvelnet-laravel-easycart/health.svg)](https://phpackages.com/packages/cyvelnet-laravel-easycart)
```

###  Alternatives

[psalm/plugin-laravel

Psalm plugin for Laravel

3345.1M337](/packages/psalm-plugin-laravel)[wearepixel/laravel-cart

A cart implementation for Laravel

1355.6k](/packages/wearepixel-laravel-cart)[realrashid/cart

Meet Cart — your ultimate solution for seamless shopping cart functionality in Laravel applications. Cart simplifies the complexities of shopping cart operations, from product additions to total calculations, ensuring a frictionless user experience.

1104.0k](/packages/realrashid-cart)

PHPackages © 2026

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