PHPackages                             anam/lara-phpcart - 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. anam/lara-phpcart

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

anam/lara-phpcart
=================

Laravel php shopping cart

v1.0(7y ago)53.3k1[1 issues](https://github.com/anam-hossain/lara-phpcart/issues)MITPHPPHP &gt;=5.4.0

Since Feb 26Pushed 7y ago1 watchersCompare

[ Source](https://github.com/anam-hossain/lara-phpcart)[ Packagist](https://packagist.org/packages/anam/lara-phpcart)[ Docs](https://github.com/anam-hossain/lara-phpcart)[ RSS](/packages/anam-lara-phpcart/feed)WikiDiscussions master Synced today

READMEChangelog (1)DependenciesVersions (2)Used By (0)

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

[](#lara-phpcart)

Laravel PHP shopping cart

Features
--------

[](#features)

- Simple API
- Support multiple cart instances

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

[](#requirements)

- Laravel 5+

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

[](#installation)

Lara-phpcart is available via Composer

```
$ composer require anam/lara-phpcart
```

Integrations
------------

[](#integrations)

#### Laravel 5.5+ integrations

[](#laravel-55-integrations)

##### Package Discovery

[](#package-discovery)

`anam/lara-phpcart` utilize the Laravel's package auto discovery feature. So, you don't need to add manually Service provider and Facade in Laravel application's config/app.php. Laravel will automatically register the service provider and facades for you.

#### Laravel &lt; 5.5 integrations

[](#laravel--55-integrations)

After you have installed the Laravel-PHPCart, open the config/app.php file which is included with Laravel and add the following lines.

In the $providers array add the following service provider.

```
'Anam\Phpcart\CartServiceProvider'
```

Add the facade of this package to the $aliases array.

```
'Cart' => 'Anam\Phpcart\Facades\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 Anam\Phpcart\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
]);
```

###  Health Score

29

—

LowBetter than 57% of packages

Maintenance16

Infrequent updates — may be unmaintained

Popularity27

Limited adoption so far

Community5

Small or concentrated contributor base

Maturity55

Maturing project, gaining track record

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

Unknown

Total

1

Last Release

2685d ago

### Community

Maintainers

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

---

Tags

cartshopping cartLaravel shopping cartLaravel cartLaravel php cart

### Embed Badge

![Health badge](/badges/anam-lara-phpcart/health.svg)

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

###  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)
