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

ActiveLibrary

sky2002/laravel-shopping-cart
=============================

Shopping cart package for laravel

8.2.2.1(1y ago)0181MITPHPPHP &gt;=7.2

Since Jun 27Pushed 1y agoCompare

[ Source](https://github.com/uServe-UP/laravel-shopping-cart)[ Packagist](https://packagist.org/packages/sky2002/laravel-shopping-cart)[ RSS](/packages/sky2002-laravel-shopping-cart/feed)WikiDiscussions master Synced 1mo ago

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

Laravel Shopping Cart
=====================

[](#laravel-shopping-cart)

This Shopping Cart is From melihovv/laravel-shopping-cart.

Because melihovv/laravel-shopping-cart has been archived. I copied the files and update.

[![GitHub Workflow Status](https://github.com/sky2002/laravel-shopping-cart/workflows/Run%20tests/badge.svg)](https://github.com/sky2002/laravel-shopping-cart/actions)[![styleci](https://camo.githubusercontent.com/87c2f4e388450fc74f44e7c0372f3bb7ac6f202dfb75a0fbbe19c24f8861fa20/68747470733a2f2f7374796c6563692e696f2f7265706f732f39353435353937372f736869656c64)](https://styleci.io/repos/95455977)

[![Packagist](https://camo.githubusercontent.com/91d9135d3e526f0d6c98d786a4e7cb84be4a8617979b4780c34c501065c96703/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f736b79323030322f6c61726176656c2d73686f7070696e672d636172742e737667)](https://packagist.org/packages/sky2002/laravel-shopping-cart)[![Packagist](https://camo.githubusercontent.com/c628c9f9967dabbeaee9da9c152b0bc1ebd4cbb1077677c3c00a3ec2ada215fc/68747470733a2f2f706f7365722e707567782e6f72672f736b79323030322f6c61726176656c2d73686f7070696e672d636172742f642f746f74616c2e737667)](https://packagist.org/packages/sky2002/laravel-shopping-cart)[![Packagist](https://camo.githubusercontent.com/7e1098e828852dcceebf9ed2a96c353cfe89d5a07a9b5b5d2ee74ed41d6d446e/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f736b79323030322f6c61726176656c2d73686f7070696e672d636172742e737667)](https://packagist.org/packages/sky2002/laravel-shopping-cart)

Install
-------

[](#install)

Install via composer

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

```

### Publish configuration file and migrations

[](#publish-configuration-file-and-migrations)

```
php artisan vendor:publish --provider="sky2002\ShoppingCart\ServiceProvider"

```

### Run migrations

[](#run-migrations)

```
php artisan migrate

```

Overview
--------

[](#overview)

- [Usage](#usage)
- [Instances](#instances)
- [Storage](#storage)
- [Coupons](#coupons)

Usage
-----

[](#usage)

Regiser facade in config/app.php

```
'Cart' => 'sky2002\ShoppingCart\Facades\ShoppingCart',

```

or

```
use sky2002\ShoppingCart\Facades\ShoppingCart as Cart;

```

in the below examples.

The shopping cart gives you the following methods to use:

### Cart::add()

[](#cartadd)

Add an item to the shopping cart.

```
$cartItem = Cart::add($id, $name, $price, $quantity);
$cartItem = Cart::add($id, $name, $price, $quantity, [
    'color' => 'white',
]);
```

### Cart::remove()

[](#cartremove)

Remove the item with the specified unique id from the shopping cart. Unique id is used to store items with the same `$id`, but different `$options`.

```
$cartItem = Cart::add($id, $name, $price, $quantity);

// ...

Cart::remove($cartItem->getUniqueId())
```

### Cart::has()

[](#carthas)

Check if the shopping cart contains the item with the specified unique id.

```
$cartItem = Cart::add($id, $name, $price, $quantity);

// ...

if (Cart::has($cartItem->getUniqueId())) {
    // Do smth.
}
```

### Cart::get()

[](#cartget)

Get an item in the shopping cart by its unique id.

```
$cartItem = Cart::add($id, $name, $price, $quantity);

// ...

$cartItem = Cart::get($cartItem->getUniqueId());
```

### Cart::content()

[](#cartcontent)

Get all items in the shopping cart.

### Cart::clear()

[](#cartclear)

Clear the shopping cart.

### Cart::count()

[](#cartcount)

Return number of items in the shopping cart. This method does not summarize quantities of item. For example, there are 3 books and 1 iPhone in the shopping cart, so this method returns 2.

### Cart::getTotal()

[](#cartgettotal)

Return total price of all items in the shopping cart.

```
Cart::add(1, 'iPhone 7', 500, 1);
Cart::add(1, 'iPad Pro', 700, 2);
Cart::getTotal(); // return 1900
```

Instances
---------

[](#instances)

The package supports multiple instances of the cart. Some examples:

```
Cart::instance('shopping')->add('192ao12', 'Product 1', 100, 10);

// Store and get the content of the 'shopping' cart
Cart::store->content();

Cart::instance('wishlist')->add('sdjk922', 'Product 2', 50, 1, ['size' => 'medium']);

// Store and get the content of the 'wishlist' cart
Cart::store()->content();

// If you want to get the content of the 'shopping' cart again
Cart::instance('shopping')->restore()->content();
```

**The default cart instance is called `default`, so when you're not using instances,`Cart::content();` is the same as `Cart::instance('default')->content()`.**

### Cart::instance()

[](#cartinstance)

Set current instance name.

### Cart::currentInstance()

[](#cartcurrentinstance)

Get current instance name.

Storage
-------

[](#storage)

Currently there are two possible storage to persist shopping cart:

- Database
- Redis

You can choose one by specifying repository class name in config

```
// config/shopping-cart.php

'repository' => \sky2002\ShoppingCart\Repositories\ShoppingCartDatabaseRepository::class,
// or
'repository' => \sky2002\ShoppingCart\Repositories\ShoppingCartRedisRepository::class,
```

In order to use redis storage you also need to install `predis/predis` package.

### Cart::store()

[](#cartstore)

Persist current shopping cart instance to storage.

```
Cart::store($user->id);
Cart::instance('cart')->store($user->id);
Cart::instance('wishlist')->store($user->id);
```

### Cart::restore()

[](#cartrestore)

Restore shopping cart instance to storage.

```
Cart::restore($user->id);
Cart::instance('cart')->restore($user->id);
Cart::instance('wishlist')->restore($user->id);
```

### Cart::destroy()

[](#cartdestroy)

Remove shopping cart instance from storage.

```
Cart::destroy($user->id);
Cart::instance('cart')->destroy($user->id);
Cart::instance('wishlist')->destroy($user->id);
```

Coupons
-------

[](#coupons)

You can easily add discount coupons to shopping cart. Currently there are two types of coupons:

- FixedDiscountCoupon
- PercentDiscountCoupon

Related methods:

### Cart::addCoupon()

[](#cartaddcoupon)

Add coupon to cart.

```
Cart::addCoupon(new FixedDiscountCoupon($name, $discount));
Cart::addCoupon(new PercentDiscountCoupon($name, 0.1)); // 10% discount
```

### Cart::coupons()

[](#cartcoupons)

Returns all coupons.

### Cart::getTotalWithCoupons()

[](#cartgettotalwithcoupons)

Returns total price with applied coupons.

```
Cart::add(1, 'iPhone 7', 500, 1);
Cart::add(1, 'iPad Pro', 700, 2);
Cart::addCoupon(new FixedDiscountCoupon($name, 300));
Cart::getTotal(); // return 1900 - 300 = 1600
```

###  Health Score

34

—

LowBetter than 77% of packages

Maintenance31

Infrequent updates — may be unmaintained

Popularity10

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity72

Established project with proven stability

 Bus Factor1

Top contributor holds 64.8% 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 ~40 days

Recently: every ~197 days

Total

63

Last Release

725d ago

Major Versions

0.0.1 → 5.5.02017-08-30

5.8.0 → 6.02019-09-07

6.0 → 7.02020-03-07

7.1.0 → 8.0.02021-07-08

### Community

Maintainers

![](https://www.gravatar.com/avatar/51aa21003f49bf2327d0556d633917601e34b2ddfcf4f1534adf2fc333985a8c?d=identicon)[sky2002](/maintainers/sky2002)

---

Top Contributors

[![uServe-UP](https://avatars.githubusercontent.com/u/59178319?v=4)](https://github.com/uServe-UP "uServe-UP (103 commits)")[![melihovv](https://avatars.githubusercontent.com/u/8608721?v=4)](https://github.com/melihovv "melihovv (54 commits)")[![Andrewearls](https://avatars.githubusercontent.com/u/18337951?v=4)](https://github.com/Andrewearls "Andrewearls (1 commits)")[![bitw](https://avatars.githubusercontent.com/u/662422?v=4)](https://github.com/bitw "bitw (1 commits)")

---

Tags

laravelcartshopping cart

###  Code Quality

TestsPHPUnit

### Embed Badge

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

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

###  Alternatives

[larastan/larastan

Larastan - Discover bugs in your code without running it. A phpstan/phpstan extension for Laravel

6.4k43.5M5.2k](/packages/larastan-larastan)[laravel/passport

Laravel Passport provides OAuth2 server support to Laravel.

3.4k85.0M532](/packages/laravel-passport)[mongodb/laravel-mongodb

A MongoDB based Eloquent model and Query builder for Laravel

7.1k7.2M71](/packages/mongodb-laravel-mongodb)[laravel/pulse

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

1.7k12.1M99](/packages/laravel-pulse)[dyrynda/laravel-model-uuid

This package allows you to easily work with UUIDs in your Laravel models.

4802.8M8](/packages/dyrynda-laravel-model-uuid)[mehdi-fathi/eloquent-filter

Eloquent Filter adds custom filters automatically to your Eloquent Models in Laravel.It's easy to use and fully dynamic, just with sending the Query Strings to it.

450191.6k1](/packages/mehdi-fathi-eloquent-filter)

PHPackages © 2026

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