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

ActivePackage

munna/shopping-cart
===================

1.0.0(5y ago)61432MITPHP

Since Jan 14Pushed 5y ago2 watchersCompare

[ Source](https://github.com/MunnaAhmed/ShoppingCart)[ Packagist](https://packagist.org/packages/munna/shopping-cart)[ RSS](/packages/munna-shopping-cart/feed)WikiDiscussions 1.0 Synced today

READMEChangelogDependenciesVersions (1)Used By (0)

[![](https://camo.githubusercontent.com/f5236ec48cf8cb3fc52cd267d41ca4cc73c9aa0e5c79f4936181d490531077d7/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6973737565732f4d756e6e6141686d65642f53686f7070696e6743617274)](https://github.com/MunnaAhmed/ShoppingCart/issues)[![](https://camo.githubusercontent.com/07f449650eddf001d333e7b715d9e64116838a97c6ac8edcec5d9c0f84c66c9a/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f666f726b732f4d756e6e6141686d65642f53686f7070696e6743617274)](https://github.com/MunnaAhmed/ShoppingCart/network/members)[![](https://camo.githubusercontent.com/542fad7003acec641bd6fadf497fcd8caa7c10b8b847d5e79fc9aea3ebce9676/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f73746172732f4d756e6e6141686d65642f53686f7070696e6743617274)](https://github.com/MunnaAhmed/ShoppingCart/stargazers)[![](https://camo.githubusercontent.com/8ce781a8f0d2dd11cfa6ac658f2980e859c0041ff5b612138910d18c9e789264/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f4d756e6e6141686d65642f53686f7070696e6743617274)](https://packagist.org/packages/munna/shopping-cart)

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

[](#laravel-shopping-cart)

More flexible and easy cart system compatible with Laravel version 5.6, 5.7, 5.8, 6, 7 and 8.

Installing Shopping Cart
------------------------

[](#installing-shopping-cart)

Next, run the Composer command to install the latest stable version:

```
composer require munna/shopping-cart
```

Full Overview In Short
----------------------

[](#full-overview-in-short)

- [Add](#Add)
- [Update](#Update)
- [Remove](#Remove)
- [Search](#Search)
- [Calculation](#Calculation)
- [Total](#Total)
- [Subtotal](#Subtotal)
- [Count](#Count)
- [Shipping](#Shipping)
- [Tax](#Tax)
- [Discount](#Discount)
- [Items](#Items)
- [Info](#Info)
- [Clear](#Clear)
- [Video Tutorial](#Video)

Create A Class Instance
-----------------------

[](#create-a-class-instance)

munna\\shopping-cart provide two type of instances. You can call the Cart class directly as static class or you can create class object.

### First we check how to create a class object instance

[](#first-we-check-how-to-create-a-class-object-instance)

```
// Use this as namespace
use Munna\ShoppingCart\Cart;

// call the cart class
// as a parameter we can pass the instance name.
// default instance is = shopping-cart
// you can use any of instances name as you like
$cart = new Cart();
// Example
$info = $cart->info();
// You will get all info about your default instance like as bellow
return $info;
```

as a json return look like

```
{
    "instance": "shopping-cart",
    "count": 0,
    "shipping": 0,
    "discount": 0,
    "tax": 0,
    "subtotal": 0,
    "total": 0,
    "items": []
}
```

### Second we check how to create a static class instance

[](#second-we-check-how-to-create-a-static-class-instance)

```
// Use this as namespace
use Munna\ShoppingCart\Facades\Cart;

// init the cart class by calling init() method
// as a parameter we can pass the instance name into the init() method.
// default instance is = shopping-cart
// you can use any of instances name as you like

$cart = Cart::init();
// Example
return Cart::info();

// If you want to use this globally as static class, then just add this line
// at your config/app.php into aliases array
'Cart' => Munna\ShoppingCart\Facades\Cart::class,

// You will get all info about your default instance like as bellow
```

as a json return look like

```
{
    "instance": "shopping-cart",
    "count": 0,
    "shipping": 0,
    "discount": 0,
    "tax": 0,
    "subtotal": 0,
    "total": 0,
    "items": []
}
```

How can we use instance
-----------------------

[](#how-can-we-use-instance)

```
// default instance = shoppint-cart

// 1st Example
$cart = new Cart('whishlist');
// Example
return $cart->info();

// 2nd Example
Cart::init('whishlist');
// Example
$cart = Cart::info();
return $cart;
```

Add
---

[](#add)

### Cart::add() or $cart-&gt;add()

[](#cartadd-or-cart-add)

```
// You must maintaince these parameter value

// Require Fields
$product_id  = "You product Id", // Required
$product_name = "Product Name", // Required
$product_qty = "Product Quantity", // Required
$product_price = "Product Price", // Required

// Optional Fields
$product_weight = 0, // Optional
$product_thumb = null, // Optional
$discount = 0, // Optional
$shipping_charge = 0, // Optional
$tax = 0, // Optional
$product_info = [];// Optional

// 1st example
$cart = new Cart();
$cart->add($product_id, $product_name, $product_qty, $product_price, $product_weight = 0, $product_thumb = null, $discount = 0, $shipping_charge = 0, $tax = 0, $product_info = []);

// 2nd example
Cart::add($product_id, $product_name, $product_qty, $product_price, $product_weight = 0, $product_thumb = null, $discount = 0, $shipping_charge = 0, $tax = 0, $product_info = []);
```

After successful you will get this on return

```
{
    "status": true,
    "message": "Product Has Been Added To Shopping Cart",
    "instance": "shopping-cart",
    "uid": "82qdiieeqvl0wftwyv7b1cfhidi4ry6k"
}
```

Update
------

[](#update)

### Cart::update() or $cart-&gt;update()

[](#cartupdate-or-cart-update)

```
// You must maintaince these parameter value

// Require Fields
$uid  = "You uid Id", // Required  // Like as something 82qdiieeqvl0wftwyv7b1cfhidi4ry6k
$quantity = 3; // Required

// 1st example
$cart = new Cart();
$cart->update($uid, $quantity);

// 2nd example
Cart::update($uid, $quantity);
```

After successful you will get this on return

```
{
    "status": true,
    "message": "Product Has Been Updated",
    "instance": "shopping-cart",
    "uid": "82qdiieeqvl0wftwyv7b1cfhidi4ry6k"
}
```

Remove
------

[](#remove)

### Cart::remove() or $cart-&gt;remove()

[](#cartremove-or-cart-remove)

```
// You must maintaince these parameter value

// Require Fields
$uid  = "You uid Id", // Required  // Like as something m1ueddkrrayhkwi4prtjvxfyoytjmxpz

// 1st example
$cart = new Cart();
$cart->remove($uid);

// 2nd example
Cart::remove($uid);
```

After successful you will get this on return

```
{
    "status": true,
    "message": "Product Has Been Removed",
    "instance": "shopping-cart",
    "uid": "82qdiieeqvl0wftwyv7b1cfhidi4ry6k"
}
```

Search
------

[](#search)

### Cart::search() or $cart-&gt;search() or Cart::get() or $cart-&gt;get()

[](#cartsearch-or-cart-search-or-cartget-or-cart-get)

```
// You must maintaince these parameter value

// Require Fields
$uid  = "You uid Id", // Required  // Like as something m1ueddkrrayhkwi4prtjvxfyoytjmxpz

// 1st example
$cart = new Cart();
$cart->search($uid);
$cart->get($uid);

// 2nd example
Cart::search($uid);
Cart::get($uid);
```

After successful you will get this on return

```
{
    "status": true,
    "message": "Product Item Found",
    "instance": "shopping-cart",
    "uid": "dsnufjalsd6cgohogi2aw3dyljb3y3kf",
    "product": 6,
    "name": "Product 6",
    "price": 80.5,
    "qty": 1,
    "weight": 0,
    "discount": 0,
    "tax": 0,
    "shipping": 0,
    "thumb": null,
    "options": [],
    "subtotal": "80.50",
    "total": "80.50",
    "created_at": "2021-01-14T22:44:33.411759Z",
    "updated_at": null
}
```

Clear
-----

[](#clear)

### Cart::clear() or $cart-&gt;clear()

[](#cartclear-or-cart-clear)

```
// 1st example
$cart = new Cart();
$cart->clear();

// 2nd example
Cart::clear();
```

After successful you will get this on return

```
{
    "status": true,
    "message": "Cart items has been cleared"
}
```

Calucation
==========

[](#calucation)

Total
-----

[](#total)

### Cart::total() or $cart-&gt;total()

[](#carttotal-or-cart-total)

```
// 1st example
$cart = new Cart();
$cart->total();

// 2nd example
Cart::total();
```

Subtotal
--------

[](#subtotal)

### Cart::subtotal() or $cart-&gt;subtotal()

[](#cartsubtotal-or-cart-subtotal)

```
// 1st example
$cart = new Cart();
$cart->subtotal();

// 2nd example
Cart::subtotal();
```

Discount
--------

[](#discount)

### Cart::discount() or $cart-&gt;discount()

[](#cartdiscount-or-cart-discount)

```
// 1st example
$cart = new Cart();
$cart->discount();

// 2nd example
Cart::discount();
```

Shipping
--------

[](#shipping)

### Cart::shipping() or $cart-&gt;shipping()

[](#cartshipping-or-cart-shipping)

```
// 1st example
$cart = new Cart();
$cart->shipping();

// 2nd example
Cart::shipping();
```

Tax
---

[](#tax)

### Cart::tax() or $cart-&gt;tax()

[](#carttax-or-cart-tax)

```
// 1st example
$cart = new Cart();
$cart->tax();

// 2nd example
Cart::tax();
```

Count
-----

[](#count)

### Cart::count() or $cart-&gt;count()

[](#cartcount-or-cart-count)

```
// 1st example
$cart = new Cart();
$cart->count();

// 2nd example
Cart::count();
```

Items
-----

[](#items)

### Cart::items() or $cart-&gt;items()

[](#cartitems-or-cart-items)

```
// 1st example
$cart = new Cart();
$cart->items();

// 2nd example
Cart::items();

// items() methos support a parameter that can able to sorted your cart item by ascending
// You can sort your item by price, total, subtotal, product name or any key that exists.

// Example

Cart::items('price');
// or
Cart::items('name');
// or
Cart::items('qty');
// or
Cart::items('total')  //etc
```

Look like as

```
[
    {
        "uid": "h6zc3duk5cqu69y5tcof0u01iwx47tyy",
        "product": 6,
        "name": "Product 6",
        "price": 80.5,
        "qty": 1,
        "weight": 0,
        "discount": 0,
        "tax": 0,
        "shipping": 0,
        "thumb": null,
        "options": [],
        "subtotal": "80.50",
        "total": "80.50",
        "created_at": "2021-01-14T23:00:14.590324Z",
        "updated_at": null
    },
    {
        "uid": "iafu81ochafwyeehpkviy5s7dwdsogbf",
        "product": 1,
        "name": "Product 1",
        "price": 80.5,
        "qty": 1,
        "weight": 0,
        "discount": 0,
        "tax": 0,
        "shipping": 0,
        "thumb": null,
        "options": [],
        "subtotal": "80.50",
        "total": "80.50",
        "created_at": "2021-01-14T23:00:23.505786Z",
        "updated_at": null
    },
    {
        "uid": "hrkzcpyxxkjup4hxz1td86yhhbyyq71g",
        "product": 2,
        "name": "Product 2",
        "price": 100,
        "qty": 3,
        "weight": 0,
        "discount": 0,
        "tax": 0,
        "shipping": 0,
        "thumb": null,
        "options": [],
        "subtotal": "300.00",
        "total": "300.00",
        "created_at": "2021-01-14T23:00:34.813746Z",
        "updated_at": null
    }
]
```

Info
----

[](#info)

### Cart::info() or $cart-&gt;info()

[](#cartinfo-or-cart-info)

### Provide all qurey like total(), subtotal(), tax(), discount(), count() and others

[](#provide-all-qurey-like-total-subtotal-tax-discount-count-and-others)

```
// 1st example
$cart = new Cart();
$cart->info();

// 2nd example
Cart::info();

// info() methos support a parameter that can able to sorted your cart item by ascending
// You can sort your item by price, total, subtotal, product name or any key that exists.

// Example
Cart::info('price');
// or
Cart::info('name');
// or
Cart::info('qty');
// or
Cart::info('total')  //etc
```

Like as

```
{
    "instance": "shopping-cart",
    "count": 3,
    "shipping": "0.00",
    "discount": "0.00",
    "tax": "0.00",
    "subtotal": "461.00",
    "total": "461.00",
    "items": [
        {
            "uid": "h6zc3duk5cqu69y5tcof0u01iwx47tyy",
            "product": 6,
            "name": "Product 6",
            "price": 80.5,
            "qty": 1,
            "weight": 0,
            "discount": 0,
            "tax": 0,
            "shipping": 0,
            "thumb": null,
            "options": [],
            "subtotal": "80.50",
            "total": "80.50",
            "created_at": "2021-01-14T23:00:14.590324Z",
            "updated_at": null
        },
        {
            "uid": "iafu81ochafwyeehpkviy5s7dwdsogbf",
            "product": 1,
            "name": "Product 1",
            "price": 80.5,
            "qty": 1,
            "weight": 0,
            "discount": 0,
            "tax": 0,
            "shipping": 0,
            "thumb": null,
            "options": [],
            "subtotal": "80.50",
            "total": "80.50",
            "created_at": "2021-01-14T23:00:23.505786Z",
            "updated_at": null
        },
        {
            "uid": "hrkzcpyxxkjup4hxz1td86yhhbyyq71g",
            "product": 2,
            "name": "Product 2",
            "price": 100,
            "qty": 3,
            "weight": 0,
            "discount": 0,
            "tax": 0,
            "shipping": 0,
            "thumb": null,
            "options": [],
            "subtotal": "300.00",
            "total": "300.00",
            "created_at": "2021-01-14T23:00:34.813746Z",
            "updated_at": null
        }
    ]
}
```

Video
-----

[](#video)

Check this video if you need. [![Laravel Shopping Cart](https://camo.githubusercontent.com/67ff235f5c46b8a7921b42edb9290f5b6fe7328e481850b69985f0234ca0a4e8/68747470733a2f2f69392e7974696d672e636f6d2f76692f4a46573141484e4a3357552f6d71322e6a70673f7371703d43495356694941472672733d414f6e34434c425678717a4c39555261324a387351694b467a537463325075527a41)](https://www.youtube.com/watch?v=JFW1AHNJ3WU&feature=youtu.be&ab_channel=OnlineEnergy)

License
-------

[](#license)

This package is open-sources and licensed under the [MIT license](https://opensource.org/licenses/MIT). Thank you very much. Please give a star if you love it and suggest me better.

###  Health Score

27

—

LowBetter than 49% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity17

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity51

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

1941d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/9b13b7a952ed204da64c6eb9fe587446cbe02cc028f89d1f704376e131a64a9b?d=identicon)[MunnaAhmed](/maintainers/MunnaAhmed)

---

Top Contributors

[![dev-munna](https://avatars.githubusercontent.com/u/56052563?v=4)](https://github.com/dev-munna "dev-munna (9 commits)")

---

Tags

ecommerceshopping cartLaravel shopping cartEcommerce Shopping Cart

### Embed Badge

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

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

###  Alternatives

[amsgames/laravel-shop

Package set to provide shop or e-commerce functionality (such as CART, ORDERS, TRANSACTIONS and ITEMS) to Laravel for customizable builds.

4845.9k](/packages/amsgames-laravel-shop)[silvershop/core

Provides an ecommerce product catalog, shopping cart, and order management system

11340.0k37](/packages/silvershop-core)[anam/phpcart

Simple framework agnostic shopping cart

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

1093.6k](/packages/realrashid-cart)[mahocommerce/maho

Free and open source ecommerce platform, created in 2024 on the M1 platform, PHP 8.3+

1322.1k12](/packages/mahocommerce-maho)

PHPackages © 2026

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