PHPackages                             lenius/laravel-ecommerce - 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. [Framework](/categories/framework)
4. /
5. lenius/laravel-ecommerce

ActiveLibrary[Framework](/categories/framework)

lenius/laravel-ecommerce
========================

Shopping basket package for laravel 10 &amp; 11

v2.0.6(1y ago)111.6kMITPHPPHP ^8.0CI passing

Since Jan 9Pushed 1y ago1 watchersCompare

[ Source](https://github.com/Lenius/laravel-ecommerce)[ Packagist](https://packagist.org/packages/lenius/laravel-ecommerce)[ Docs](https://github.com/Lenius/laravel-ecommerce)[ RSS](/packages/lenius-laravel-ecommerce/feed)WikiDiscussions main Synced today

READMEChangelog (10)Dependencies (9)Versions (14)Used By (0)

Ecommerce for Laravels App
==========================

[](#ecommerce-for-laravels-app)

[![Latest Version on Packagist](https://camo.githubusercontent.com/010ad5651a2e89b4a647f0e7f0036fa41f0c67a2f19d74b26a64bebbe176697b/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6c656e6975732f6c61726176656c2d65636f6d6d657263652e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/lenius/laravel-ecommerce)[![tests](https://github.com/Lenius/laravel-ecommerce/actions/workflows/tests.yml/badge.svg?branch=main)](https://github.com/Lenius/laravel-ecommerce/actions/workflows/tests.yml)[![Code Coverage](https://camo.githubusercontent.com/6774a417735fd22a96d2e3386f7e138a4a9ed4c4e59ad2da7b1496a2fc4d779c/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f4c656e6975732f6c61726176656c2d65636f6d6d657263652f6261646765732f636f7665726167652e706e673f623d6d61696e)](https://scrutinizer-ci.com/g/Lenius/laravel-ecommerce/?branch=main)[![Total Downloads](https://camo.githubusercontent.com/b08e8b95ac8b5f479da5a21aea318c3763746722531888dca7e4187552b7fb86/68747470733a2f2f706f7365722e707567782e6f72672f6c656e6975732f6c61726176656c2d65636f6d6d657263652f646f776e6c6f6164732e737667)](https://packagist.org/packages/laravel-ecommerce)[![License](https://camo.githubusercontent.com/619ea88c296fd58abdd02e6e026b32625631b48e59860051b999d7cf485fc2c6/68747470733a2f2f706f7365722e707567782e6f72672f6c656e6975732f6c61726176656c2d65636f6d6d657263652f6c6963656e73652e737667)](https://packagist.org/packages/Lenius/laravel-ecommerce)

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

[](#installation)

You can install this package via composer using:

```
composer require lenius/laravel-ecommerce
```

You can then export the configuration:

```
php artisan vendor:publish --provider="Lenius\LaravelEcommerce\EcommerceServiceProvider" --tag="config"
php artisan vendor:publish --provider="Lenius\LaravelEcommerce\EcommerceServiceProvider" --tag="lang"
php artisan vendor:publish --provider="Lenius\LaravelEcommerce\EcommerceServiceProvider" --tag="views"
```

Overview
--------

[](#overview)

Look at one of the following topics to learn more

- [Usage](#usage)
- [Events](#events)

Usage
-----

[](#usage)

The shoppingcart gives you the following methods to use:

### Cart::insert()

[](#cartinsert)

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

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

```
Cart::insert(new Item([
    'id'       => 'foo',
    'name'     => 'bar',
    'price'    => 100,
    'quantity' => 2,
    'weight'   => 300
]));
```

Cart::insert() accept a class which implements ItemInterface

```
class CustomItem implements ItemInterface
{

}
```

### Inserting items with options into the cart

[](#inserting-items-with-options-into-the-cart)

Inserting an item into the cart is easy. The required keys are id, name, price and quantity, although you can pass over any custom data that you like. If option items contains price or weight there values are added to the total weight / price of the product.

```
Cart::insert(new Item([
    'id'         => 'foo',
    'name'       => 'bar',
    'price'      => 100,
    'quantity'   => 2,
    'weight'     => 300,
    'options'    => [
       [
        'name'   => 'Size',
        'value'  => 'L',
        'weight' => 50,
        'price'  => 10
       ],
     ],
]));
```

### Setting the tax rate for an item

[](#setting-the-tax-rate-for-an-item)

Another key you can pass to your insert method is tax'. This is a percentage which you would like to be added onto the price of the item.

In the below example we will use 25% for the tax rate.

```
Cart::insert(new Item([
    'id'       => 'mouseid',
    'name'     => 'Mouse',
    'price'    => 100,
    'quantity' => 1,
    'tax'      => 25,
    'weight'   => 200
]));
```

### Updating items in the cart

[](#updating-items-in-the-cart)

You can update items in your cart by updating any property on a cart item. For example, if you were within a cart loop then you can update a specific item using the below example.

```
foreach (Cart::contents() as $item) {
    $item->name = 'Foo';
    $item->setQuantity(1);
}
```

### Destroying/emptying the cart

[](#destroyingemptying-the-cart)

You can completely empty/destroy the cart by using the `destroy()` method.

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

### Retrieve the cart contents

[](#retrieve-the-cart-contents)

You can loop the cart contents by using the following method

```
Cart::contents();
```

You can also return the Cart items as an array by passing true as the first argument

```
Cart::contents(true);
```

### Check if the Cart has an item

[](#check-if-the-cart-has-an-item)

```
Cart::has($itemIdentifier);
```

### Remove an item from the Cart

[](#remove-an-item-from-the-cart)

```
Cart::remove($itemIdentifier)
```

### Increment an item from the Cart

[](#increment-an-item-from-the-cart)

```
Cart::inc($itemIdentifier)
```

### Decrement an item from the Cart

[](#decrement-an-item-from-the-cart)

```
Cart::dec($itemIdentifier)
```

Events
------

[](#events)

The cart also has events build in. There are five events available for you to listen for.

EventFiredParameterCartItemUpdatedWhen an item in the cart was updated.The `CartItem` that was updated.CartItemRemovedWhen an item is removed from the cart.The `CartItem` that was removed.CartItemDecreasedWhen an item is dec from the cart.The `CartItem` that was decreased.CartItemIncrementedWhen an item is inc from the cart.The `CartItem` that was incremented.CartDestroyedWhen the cart was destroyed.-Testing
-------

[](#testing)

Run the tests with:

```
composer psalm
composer stan
composer test
composer test-coverage
```

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

[](#contributing)

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

Security
--------

[](#security)

If you discover any security-related issues, please email instead of using the issue tracker.

License
-------

[](#license)

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

###  Health Score

38

—

LowBetter than 83% of packages

Maintenance41

Moderate activity, may be stable

Popularity24

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity66

Established project with proven stability

 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

Every ~137 days

Recently: every ~251 days

Total

12

Last Release

494d ago

Major Versions

v1.0.4 → v2.0.02022-05-23

PHP version history (2 changes)v1.0.0PHP ^7.4 || ^8.0

v1.0.4PHP ^8.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/8539c9af6113bdef769983294e463381bace6566ecc7c8daaa7dcfe1516c19de?d=identicon)[lenius](/maintainers/lenius)

---

Top Contributors

[![cjonstrup](https://avatars.githubusercontent.com/u/576584?v=4)](https://github.com/cjonstrup "cjonstrup (89 commits)")

---

Tags

laravelphpshopping-cartframeworklaravele-commerceLaravel Basketlenius

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StylePHP CS Fixer

### Embed Badge

![Health badge](/badges/lenius-laravel-ecommerce/health.svg)

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

###  Alternatives

[spatie/laravel-permission

Permission handling for Laravel 12 and up

12.9k102.4M1.4k](/packages/spatie-laravel-permission)[psalm/plugin-laravel

Psalm plugin for Laravel

3355.3M346](/packages/psalm-plugin-laravel)[laravel/ai

The official AI SDK for Laravel.

1.0k3.2M201](/packages/laravel-ai)[laravel/passport

Laravel Passport provides OAuth2 server support to Laravel.

3.5k91.9M595](/packages/laravel-passport)[laravel/pulse

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

1.7k15.1M132](/packages/laravel-pulse)[roots/acorn

Framework for Roots WordPress projects built with Laravel components.

9762.4M131](/packages/roots-acorn)

PHPackages © 2026

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