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

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

miladev/lara-cart
=================

Laravel shopping cart

1.3(2y ago)1481MITPHPPHP &gt;=8.0

Since Aug 9Pushed 3w ago1 watchersCompare

[ Source](https://github.com/miladev95/laracart)[ Packagist](https://packagist.org/packages/miladev/lara-cart)[ Docs](https://github.com/miladev95/lara-cart)[ RSS](/packages/miladev-lara-cart/feed)WikiDiscussions master Synced today

READMEChangelog (5)DependenciesVersions (5)Used By (0)

Lara-PHPCart
============

[](#lara-phpcart)

Laravel PHP shopping cart

[![Latest Stable Version](https://camo.githubusercontent.com/1389cc1ecb3e3ec36b9403ef15d1ee41aa39c2b82de6bf77195a614cb0456c47/68747470733a2f2f706f7365722e707567782e6f72672f6d696c616465762f6c6172612d636172742f76)](//packagist.org/packages/miladev/lara-cart)[![License](https://camo.githubusercontent.com/08f047318e15c8861cae9aaba76cb47cd530fcb48c7fb7e9c81a161cedfce329/68747470733a2f2f706f7365722e707567782e6f72672f6d696c616465762f6c6172612d636172742f6c6963656e7365)](//packagist.org/packages/miladev/lara-cart)[![Total Downloads](https://camo.githubusercontent.com/42fd3a8716a76c34119017ef9a9802b78ae397b1461a30d3b157000fb0b70589/68747470733a2f2f706f7365722e707567782e6f72672f6d696c616465762f6c6172612d636172742f646f776e6c6f616473)](//packagist.org/packages/miladev/lara-cart)

[![](https://camo.githubusercontent.com/d6ee11871bfe8c58e28e4c6ed67dfc79eabda39795ba5df8316232094ee34876/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6973737565732f6d696c6164657639352f6c617261636172742e737667)](https://github.com/miladev95/laracart/issues)[![](https://camo.githubusercontent.com/7dd27b2c87747b7af318e1ec91b7e011a642fd879d3633c718ad6e1872099a48/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f73746172732f6d696c6164657639352f6c617261636172742e737667)](https://github.com/miladev95/laracart/stargazers)[![](https://camo.githubusercontent.com/f90888c71416c7400a9846ea706df9ab4444727d9df41f92cddababec9606686/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f666f726b732f6d696c6164657639352f6c617261636172742e737667)](https://github.com/miladev95/laracart/network)

Features
--------

[](#features)

- Simple API
- Support multiple cart instances

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

[](#requirements)

- Laravel 5+

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

[](#installation)

Lara-phpcart is available via Composer

```
$ composer require miladev/lara-cart
```

You can now use this facade in place of instantiating the Cart yourself in the following examples.

Usage
-----

[](#usage)

### Add Item

[](#add-item)

The add method required `id`, `name`, `price` and `quantity` keys. However, you can pass any data that your application required.

```
use Miladev\Laracart\Cart;

$cart = new Cart();

$cart->add([
    'id'       => 1001,
    'name'     => 'Skinny Jeans',
    'quantity' => 1,
    'price'    => 90
]);
```

### Update Item

[](#update-item)

```
$cart->update([
    'id'       => 1001,
    'name'     => 'Hoodie'
]);
```

### Update quantity

[](#update-quantity)

```
$cart->updateQty(1001, 3);
```

### Update price

[](#update-price)

```
$cart->updatePrice(1001, 30);
```

### Remove an Item

[](#remove-an-item)

```
$cart->remove(1001);
```

### Get all Items

[](#get-all-items)

```
$cart->getItems();
// or
$cart->items();
```

### Get an Item

[](#get-an-item)

```
$cart->get(1001);
```

### Determining if an Item exists in the cart

[](#determining-if-an-item-exists-in-the-cart)

```
$cart->has(1001);
```

### Get the total number of items in the cart

[](#get-the-total-number-of-items-in-the-cart)

```
$cart->count();
```

### Get the total quantities of items in the cart

[](#get-the-total-quantities-of-items-in-the-cart)

```
$cart->totalQuantity();
```

### Total sum

[](#total-sum)

```
$cart->getTotal();
```

### Empty the cart

[](#empty-the-cart)

```
$cart->clear();
```

### Multiple carts

[](#multiple-carts)

Lara-PHPCart supports multiple cart instances, so that you can have as many shopping cart instances on the same page as you want without any conflicts.

```
$cart = new Cart('cart1');
// or
$cart->setCart('cart2');
$cart->add([
    'id'       => 1001,
    'name'     => 'Skinny Jeans',
    'quantity' => 1,
    'price'    => 90
]);

//or
$cart->named('cart3')->add([
    'id'       => 1001,
    'name'     => 'Jeans',
    'quantity' => 2,
    'price'    => 100
]);
```

### Coupons and Promo Codes

[](#coupons-and-promo-codes)

Apply a cart-level coupon or promo code to reduce the cart total.

```
$cart->applyCoupon([
    'code'  => 'SAVE10',
    'type'  => 'percentage', // or: fixed
    'value' => 10,
]);

$discount = $cart->getDiscountAmount();
$total = $cart->getTotal();
```

Remove an applied coupon:

```
$cart->removeCoupon();
```

Future Features
---------------

[](#future-features)

- Tax calculation per item and per cart
- Discount rules and price modifiers
- Shipping methods and shipping cost calculation
- Cart fees such as handling or service fees
- Guest cart to authenticated user cart merge
- Cross-device cart synchronization
- Wishlist and saved-for-later support
- Cart item metadata and custom options
- Product model association and auto-sync from database
- Multiple cart instances with isolated totals
- Cart events and hooks for extensibility
- Currency support and locale-aware formatting
- Bulk pricing and tiered pricing rules
- Inventory and stock validation before checkout
- Cart expiration and cleanup
- Persistent storage drivers beyond session and database
- API resources for headless and frontend integrations
- Better validation and custom exceptions
- Full test coverage for all cart operations
- Support for the latest Laravel versions

###  Health Score

35

—

LowBetter than 77% of packages

Maintenance62

Regular maintenance activity

Popularity10

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity52

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

Total

3

Last Release

1016d ago

PHP version history (2 changes)1.0PHP &gt;=5.4.0

1.2PHP &gt;=8.0

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/35612406?v=4)[Milad](/maintainers/miladev95)[@miladev95](https://github.com/miladev95)

---

Top Contributors

[![miladev95](https://avatars.githubusercontent.com/u/35612406?v=4)](https://github.com/miladev95 "miladev95 (26 commits)")

---

Tags

cartshopping cartLaravel shopping cartLaravel cartLaravel php cart

### Embed Badge

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

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

###  Alternatives

[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.1k](/packages/realrashid-cart)[anam/phpcart

Simple framework agnostic shopping cart

12115.4k](/packages/anam-phpcart)[extcode/cart

Shopping Cart(s) for TYPO3

59127.0k15](/packages/extcode-cart)[wearepixel/laravel-cart

A cart implementation for Laravel

1374.8k](/packages/wearepixel-laravel-cart)[extcode/cart-products

Shopping Cart(s) for TYPO3 - Products

1048.8k](/packages/extcode-cart-products)[ultrono/laravelshoppingcart-1

Laravel 11 and above Shopping cart

1111.1k](/packages/ultrono-laravelshoppingcart-1)

PHPackages © 2026

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