PHPackages                             juliobitencourt/laravel-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. juliobitencourt/laravel-cart

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

juliobitencourt/laravel-cart
============================

A lightweight PHP Shopping Cart for Laravel 5.

v1.0.1(10y ago)381.3k13[4 issues](https://github.com/juliobitencourt/laravel-cart/issues)MITPHPPHP &gt;=5.4.0

Since Jun 12Pushed 10y ago3 watchersCompare

[ Source](https://github.com/juliobitencourt/laravel-cart)[ Packagist](https://packagist.org/packages/juliobitencourt/laravel-cart)[ Docs](http://github.com/juliobitencourt/laravel-cart)[ RSS](/packages/juliobitencourt-laravel-cart/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (3)Versions (3)Used By (0)

[![Build Status](https://camo.githubusercontent.com/03bc345c6816b5b5a11a1d1f81e2f15419574b114f7550dbbe1ac913cb81c195/68747470733a2f2f7472617669732d63692e6f72672f6a756c696f626974656e636f7572742f6c61726176656c2d636172742e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/juliobitencourt/laravel-cart)[![Latest Stable Version](https://camo.githubusercontent.com/5e75b14a9102fe961231d732501b6a81f847968ad888b01fbf4365388676e68b/68747470733a2f2f706f7365722e707567782e6f72672f6a756c696f626974656e636f7572742f6c61726176656c2d636172742f762f737461626c65)](https://packagist.org/packages/juliobitencourt/laravel-cart) [![Total Downloads](https://camo.githubusercontent.com/9b25b808a5cdec113e662a784c2ea5d0c67c835aabbfb75d01035a0ba043e60c/68747470733a2f2f706f7365722e707567782e6f72672f6a756c696f626974656e636f7572742f6c61726176656c2d636172742f646f776e6c6f616473)](https://packagist.org/packages/juliobitencourt/laravel-cart) [![Latest Unstable Version](https://camo.githubusercontent.com/e79d5b56697a313e1979fa1b67543ca771dc34f2937d310fe80377b0fc735ec8/68747470733a2f2f706f7365722e707567782e6f72672f6a756c696f626974656e636f7572742f6c61726176656c2d636172742f762f756e737461626c65)](https://packagist.org/packages/juliobitencourt/laravel-cart) [![License](https://camo.githubusercontent.com/e418da4a8fcdbf351c7bc2a3a503782af8acf5cff022f1e074ad6bbf653784a1/68747470733a2f2f706f7365722e707567782e6f72672f6a756c696f626974656e636f7572742f6c61726176656c2d636172742f6c6963656e7365)](https://packagist.org/packages/juliobitencourt/laravel-cart)

[![Code Climate](https://camo.githubusercontent.com/3e64f803a40549eb6d44effd6d0b9b6652cff0571d626f5fdc6a0894198a681f/68747470733a2f2f636f6465636c696d6174652e636f6d2f6769746875622f6a756c696f626974656e636f7572742f6c61726176656c2d636172742f6261646765732f6770612e737667)](https://codeclimate.com/github/juliobitencourt/laravel-cart)

A lightweight PHP Shopping Cart for Laravel 5.
==============================================

[](#a-lightweight-php-shopping-cart-for-laravel-5)

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

[](#installation)

### With Composer

[](#with-composer)

```
$ composer require juliobitencourt/laravel-cart

```

```
{
    "require": {
        "juliobitencourt/laravel-cart": "1.0.*"
    }
}
```

Add the service provider to your app/config/app.php in the service providers array

```
'JulioBitencourt\Cart\CartServiceProvider',
```

Publish the resources

```
php artisan vendor:publish
```

Check the config/laravel-cart.php file. The storage-driver config can have the values Session (default) or Database.

In case you use Database as the storage driver you have to run the migrations

```
php artisan migrate

```

Usage
-----

[](#usage)

### Inject the class into the constructor.

[](#inject-the-class-into-the-constructor)

```
use JulioBitencourt\Cart\Cart;

class CartController extends Controller {

	protected $cart;

	public function __construct(Cart $cart)
	{
		$this->cart = $cart;
	}
```

### Insert a new Item to the cart.

[](#insert-a-new-item-to-the-cart)

If you insert an item with the same SKU twice, the item quantity will be updated.

```
$item = [
	'sku' => '123456',
	'description' => 'PlayStation 4',
	'price' => 300,
	'quantity' => 1
];

$result = $this->cart->insert($item);
```

### Insert a Child Item.

[](#insert-a-child-item)

```
$item = [
	'sku' => '111111',
	'description' => '2 Year Protection',
	'price' => 30.50,
	'quantity' => 1
];

$result = $this->cart->insertChild($parentId, $item);
```

### Update an item

[](#update-an-item)

If you update an item with 0 quantity, it will be removed from the cart's list of items

```
$result = $this->cart->update($id, $quantity);
```

### Remove an item

[](#remove-an-item)

```
$this->cart->delete($id);
```

### Destroy the cart

[](#destroy-the-cart)

```
$this->cart->destroy();
```

### Checking if the cart is empty

[](#checking-if-the-cart-is-empty)

```
$this->cart->isEmpty(); // Returns true or false
```

### Returning an array with the list of items

[](#returning-an-array-with-the-list-of-items)

```
$this->cart->all();
```

### Count the total of items

[](#count-the-total-of-items)

```
$this->cart->totalItems();
```

### Sum the cart total price

[](#sum-the-cart-total-price)

```
$this->cart->total();
```

### Identify the cart with the e-mail.

[](#identify-the-cart-with-the-e-mail)

This is useful if you want to implement abandoned cart recovery.

```
$this->cart->setEmail($email)
```

###  Health Score

32

—

LowBetter than 72% of packages

Maintenance18

Infrequent updates — may be unmaintained

Popularity28

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity59

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

Every ~120 days

Total

2

Last Release

3873d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/64e35b4b122f5dac7ad740127a655b40cdd890f28967eb8b6c48446b069f3c77?d=identicon)[juliobitencourt](/maintainers/juliobitencourt)

---

Tags

laravelcart

### Embed Badge

![Health badge](/badges/juliobitencourt-laravel-cart/health.svg)

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

###  Alternatives

[barryvdh/laravel-ide-helper

Laravel IDE Helper, generates correct PHPDocs for all Facade classes, to improve auto-completion.

14.9k123.0M687](/packages/barryvdh-laravel-ide-helper)[matt-daneshvar/laravel-survey

Create surveys inside your Laravel app

28770.3k](/packages/matt-daneshvar-laravel-survey)[wearepixel/laravel-cart

A cart implementation for Laravel

1310.5k](/packages/wearepixel-laravel-cart)

PHPackages © 2026

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