PHPackages                             faysal0x1/laravelshoppingcart - 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. faysal0x1/laravelshoppingcart

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

faysal0x1/laravelshoppingcart
=============================

Laravel Shopping cart

v2.3.7(11mo ago)117MITPHPCI passing

Since Mar 18Pushed 11mo agoCompare

[ Source](https://github.com/faysal0x1/laravelshoppingcart)[ Packagist](https://packagist.org/packages/faysal0x1/laravelshoppingcart)[ RSS](/packages/faysal0x1-laravelshoppingcart/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (8)Dependencies (6)Versions (20)Used By (0)

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

[](#laravel-shopping-cart)

A powerful and flexible shopping cart implementation for Laravel 7, 8, 9, 10, and 11. This package provides a simple and elegant way to manage shopping carts in your Laravel applications, supporting multiple cart instances, tax calculations, and various integration methods.

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

[](#table-of-contents)

- [Installation](#installation)
- [Configuration](#configuration)
- [Basic Usage](#basic-usage)
- [Integration Methods](#integration-methods)
    - [Blade Templates](#blade-templates)
    - [Inertia.js](#inertiajs)
    - [API Integration](#api-integration)
- [Advanced Features](#advanced-features)
- [Events](#events)
- [Testing](#testing)
- [Contributing](#contributing)
- [License](#license)

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

[](#installation)

Install the package through [Composer](http://getcomposer.org/):

```
composer require faysal0x1/laravelshoppingcart
```

### Laravel &lt;= 7.0

[](#laravel--70)

For Laravel 7.0, add the service provider and alias in `config/app.php`:

```
'providers' => [
    // ...
    Gloudemans\Shoppingcart\ShoppingcartServiceProvider::class,
],

'aliases' => [
    // ...
    'Cart' => Gloudemans\Shoppingcart\Facades\Cart::class,
],
```

Configuration
-------------

[](#configuration)

Publish the configuration file:

```
php artisan vendor:publish --provider="Gloudemans\Shoppingcart\ShoppingcartServiceProvider"
```

This will create a `config/cart.php` file where you can customize:

- Tax rate
- Number format
- Default cart instance
- Database storage settings

Basic Usage
-----------

[](#basic-usage)

### Adding Items

[](#adding-items)

```
// Basic usage
Cart::add('293ad', 'Product 1', 1, 9.99);

// With options
Cart::add('293ad', 'Product 1', 1, 9.99, ['size' => 'large']);

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

// Using Buyable interface
Cart::add($product, 1, ['size' => 'large']);
```

### Updating Items

[](#updating-items)

```
$rowId = 'da39a3ee5e6b4b0d3255bfef95601890afd80709';

// Update quantity
Cart::update($rowId, 2);

// Update item details
Cart::update($rowId, ['name' => 'New Product Name']);

// Update with Buyable
Cart::update($rowId, $product);
```

### Removing Items

[](#removing-items)

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

### Getting Cart Content

[](#getting-cart-content)

```
// Get all items
$items = Cart::content();

// Get specific item
$item = Cart::get($rowId);

// Get cart total
$total = Cart::total();

// Get tax amount
$tax = Cart::tax();

// Get subtotal
$subtotal = Cart::subtotal();

// Get item count
$count = Cart::count();
```

Integration Methods
-------------------

[](#integration-methods)

### Blade Templates

[](#blade-templates)

```
// In your controller
public function index()
{
    $cart = Cart::content();
    return view('cart.index', compact('cart'));
}
```

```
{{-- In your blade view --}}
@foreach(Cart::content() as $item)

        {{ $item->name }}
        Quantity: {{ $item->qty }}
        Price: {{ $item->price }}
        @if($item->options->has('size'))
            Size: {{ $item->options->size }}
        @endif

@endforeach

    Subtotal: {{ Cart::subtotal() }}
    Tax: {{ Cart::tax() }}
    Total: {{ Cart::total() }}

```

### Inertia.js

[](#inertiajs)

```
// In your controller
public function index()
{
    return Inertia::render('Cart/Index', [
        'cart' => [
            'items' => Cart::content(),
            'subtotal' => Cart::subtotal(),
            'tax' => Cart::tax(),
            'total' => Cart::total(),
        ]
    ]);
}
```

```

      {{ item.name }}
      Quantity: {{ item.qty }}
      Price: {{ item.price }}
      Size: {{ item.options.size }}

      Subtotal: {{ cart.subtotal }}
      Tax: {{ cart.tax }}
      Total: {{ cart.total }}

export default {
  props: {
    cart: Object
  }
}

```

### API Integration

[](#api-integration)

```
// In your API controller
public function addToCart(Request $request)
{
    $validated = $request->validate([
        'id' => 'required',
        'name' => 'required',
        'qty' => 'required|numeric|min:1',
        'price' => 'required|numeric|min:0',
        'options' => 'array'
    ]);

    Cart::add($validated);

    return response()->json([
        'message' => 'Item added to cart',
        'cart' => [
            'items' => Cart::content(),
            'total' => Cart::total()
        ]
    ]);
}

public function getCart()
{
    return response()->json([
        'items' => Cart::content(),
        'subtotal' => Cart::subtotal(),
        'tax' => Cart::tax(),
        'total' => Cart::total()
    ]);
}
```

Advanced Features
-----------------

[](#advanced-features)

### Multiple Cart Instances

[](#multiple-cart-instances)

```
// Create a wishlist instance
Cart::instance('wishlist')->add('293ad', 'Product 1', 1, 9.99);

// Get wishlist content
$wishlist = Cart::instance('wishlist')->content();
```

### Database Storage

[](#database-storage)

Enable database storage in `config/cart.php`:

```
'storage' => 'database',
```

Run migrations:

```
php artisan migrate
```

### Events

[](#events)

The package fires several events you can listen to:

```
// In your EventServiceProvider
protected $listen = [
    'cart.added' => [
        'App\Listeners\CartItemAdded',
    ],
    'cart.updated' => [
        'App\Listeners\CartItemUpdated',
    ],
    'cart.removed' => [
        'App\Listeners\CartItemRemoved',
    ],
];
```

Testing
-------

[](#testing)

Run the test suite:

```
composer test
```

Contributing
------------

[](#contributing)

Please see [CONTRIBUTING.md](CONTRIBUTING.md) for details.

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE) for more information.

###  Health Score

34

—

LowBetter than 77% of packages

Maintenance50

Moderate activity, may be stable

Popularity7

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity61

Established project with proven stability

 Bus Factor1

Top contributor holds 53.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 ~85 days

Recently: every ~0 days

Total

19

Last Release

356d ago

Major Versions

1.2.2 → 2.0.02021-07-04

### Community

Maintainers

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

---

Top Contributors

[![faysal0x1](https://avatars.githubusercontent.com/u/64875731?v=4)](https://github.com/faysal0x1 "faysal0x1 (14 commits)")[![mindscms](https://avatars.githubusercontent.com/u/69152483?v=4)](https://github.com/mindscms "mindscms (11 commits)")[![alijumaan](https://avatars.githubusercontent.com/u/73781540?v=4)](https://github.com/alijumaan "alijumaan (1 commits)")

---

Tags

laravelshoppingcart

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/faysal0x1-laravelshoppingcart/health.svg)

```
[![Health](https://phpackages.com/badges/faysal0x1-laravelshoppingcart/health.svg)](https://phpackages.com/packages/faysal0x1-laravelshoppingcart)
```

###  Alternatives

[gloudemans/shoppingcart

Laravel Shoppingcart

3.7k756.7k12](/packages/gloudemans-shoppingcart)[bumbummen99/shoppingcart

Laravel Shoppingcart

518555.4k3](/packages/bumbummen99-shoppingcart)[olimortimer/laravelshoppingcart

Laravel Shoppingcart

4343.2k](/packages/olimortimer-laravelshoppingcart)

PHPackages © 2026

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