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

ActiveLibrary

mugenzo/laravel-shopping-cart
=============================

Shopping cart for laravel

1.2(5y ago)058MITPHPCI failing

Since Jun 30Pushed 5y ago1 watchersCompare

[ Source](https://github.com/Mugenzo/laravel-shopping-cart)[ Packagist](https://packagist.org/packages/mugenzo/laravel-shopping-cart)[ RSS](/packages/mugenzo-laravel-shopping-cart/feed)WikiDiscussions master Synced 2d ago

READMEChangelog (2)Dependencies (7)Versions (2)Used By (0)

LaravelShoppingCart
-------------------

[](#laravelshoppingcart)

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

[](#installation)

Run the Composer require command from the Terminal:

```
composer require mugenzo/laravel-shopping-cart

```

Now you're ready to start using the shoppingcart in your application.

Table of Contents
-----------------

[](#table-of-contents)

Look at one of the following topics to learn more about LaravelShoppingCart

- [Usage](#usage)
- [Collections](#collections)
- [Instances](#instances)
- [Models](#models)

Usage
-----

[](#usage)

The shoppingcart gives you the following methods to use:

### Cart::add()

[](#cartadd)

Adding an item to the cart is really simple, you just use the `add()` method, which accepts a variety of parameters.

In its most basic form you can specify the id, name, quantity, price and weight of the product you'd like to add to the cart.

```
Cart::add('293ad', 'Product 1', 1, 9.99, 550);
```

As an optional fifth parameter you can pass it options, so you can add multiple items with the same id, but with (for instance) a different size.

```
Cart::add('293ad', 'Product 1', 1, 9.99, 550, ['size' => 'large']);
```

**The `add()` method will return an CartItem instance of the item you just added to the cart.**

Maybe you prefer to add the item using an array? As long as the array contains the required keys, you can pass it to the method. The options key is optional.

```
Cart::add(['id' => '293ad', 'name' => 'Product 1', 'qty' => 1, 'price' => 9.99, 'weight' => 550, 'options' => ['size' => 'large']]);
```

### Cart::update()

[](#cartupdate)

To update an item in the cart, you'll first need the rowId of the item. Next you can use the `update()` method to update it.

If you simply want to update the quantity, you'll pass the update method the rowId and the new quantity:

```
$rowId = 'da39a3ee5e6b4b0d3255bfef95601890afd80709';

Cart::update($rowId, 2);
```

If you would like to update options of an item inside the cart,

```
$rowId = 'da39a3ee5e6b4b0d3255bfef95601890afd80709';

Cart::update($rowId, ['options'  => ['size' => 'small']]); // Will update the size option with new value
```

### Cart::remove()

[](#cartremove)

To remove an item for the cart, you'll again need the rowId. This rowId you simply pass to the `remove()` method and it will remove the item from the cart.

```
$rowId = 'da39a3ee5e6b4b0d3255bfef95601890afd80709';

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

### Cart::get()

[](#cartget)

If you want to get an item from the cart using its rowId, you can simply call the `get()` method on the cart and pass it the rowId.

```
$rowId = 'da39a3ee5e6b4b0d3255bfef95601890afd80709';

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

### Cart::content()

[](#cartcontent)

Of course you also want to get the carts content. This is where you'll use the `content` method. This method will return a Collection of CartItems which you can iterate over and show the content to your customers.

```
Cart::content();
```

### Cart::destroy()

[](#cartdestroy)

```
Cart::destroy();
```

### Cart::total()

[](#carttotal)

The `total()` method can be used to get the calculated total of all items in the cart, given there price and quantity.

```
Cart::total();
```

### Cart::discount()

[](#cartdiscount)

The `discount()` method can be used to get the total discount of all items in the cart.

```
Cart::discount();
```

### Cart::initial()

[](#cartinitial)

The `initial()` method can be used to get the total price of all items in the cart before applying discount.

```
Cart::initial();
```

### Cart::count()

[](#cartcount)

If you want to know how many items there are in your cart, you can use the `count()` method. This method will return the total number of items in the cart. So if you've added 2 books and 1 shirt, it will return 3 items.

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

### Cart::search()

[](#cartsearch)

To find an item in the cart, you can use the `search()` method.

```
$cart->search(function ($cartItem, $rowId) {
	return $cartItem->id === 1;
});
```

### Cart::setDiscount($type, $value)

[](#cartsetdiscounttype-value)

You can use the `setDiscount()` method to change the discount type and value that applies to Cart.

```
Cart::setDiscount('percent', 10);
$cart->setDiscount('percent', 10);
```

```
Cart::setDiscount('flat', 100);
$cart->setDiscount('flat', 100);
```

### Configuration

[](#configuration)

If you want to change Cart options, you'll have to publish the `config` file.

```
php artisan vendor:publish --provider="Mugenzo\LaravelShoppingCart\ShoppingCartServiceProvider" --tag="config"

```

This will give you a `shopping_cart_config.php` config file in which you can make the changes.

###  Health Score

25

—

LowBetter than 37% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity8

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity55

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

Unknown

Total

1

Last Release

2143d ago

### Community

Maintainers

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

---

Top Contributors

[![Mugenzo](https://avatars.githubusercontent.com/u/29299715?v=4)](https://github.com/Mugenzo "Mugenzo (1 commits)")

---

Tags

laravelshoppingcart

###  Code Quality

TestsPHPUnit

### Embed Badge

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

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

###  Alternatives

[laravel/pulse

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

1.7k12.1M99](/packages/laravel-pulse)[bumbummen99/shoppingcart

Laravel Shoppingcart

518555.4k3](/packages/bumbummen99-shoppingcart)[lukepolo/laracart

A simple cart for Laravel

583135.4k1](/packages/lukepolo-laracart)[anayarojo/shoppingcart

Laravel Shoppingcart

57175.5k](/packages/anayarojo-shoppingcart)[masterro/laravel-mail-viewer

Easily view in browser outgoing emails.

6392.1k](/packages/masterro-laravel-mail-viewer)

PHPackages © 2026

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