PHPackages                             lenius/laravel-basket - 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-basket

ActiveLibrary[Framework](/categories/framework)

lenius/laravel-basket
=====================

Shopping basket package for Laravel

v4.0.0(5y ago)197.5k8MITPHPPHP ^7.4|^8.0

Since Aug 14Pushed 5y ago5 watchersCompare

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

READMEChangelog (10)Dependencies (4)Versions (12)Used By (0)

Laravel Shopping Basket Package
===============================

[](#laravel-shopping-basket-package)

[![Total Downloads](https://camo.githubusercontent.com/ef077073588d915e4830a92b7df07f3acb8fcaf395ab925f1656fa4a525f4c43/68747470733a2f2f706f7365722e707567782e6f72672f6c656e6975732f6c61726176656c2d6261736b65742f646f776e6c6f6164732e737667)](https://packagist.org/packages/lenius/laravel-basket) [![StyleCI](https://camo.githubusercontent.com/cd2c5e34ed404e252e7d24a68213629a6f894be6acbfa01336bfcc0e53e47653/68747470733a2f2f7374796c6563692e696f2f7265706f732f31323031383235322f736869656c64)](https://styleci.io/repos/12018252) [![Latest Stable Version](https://camo.githubusercontent.com/a84cc05d0454caa238c7b44ebe7f4f790c76043b86d922c87987bc4a48308063/68747470733a2f2f706f7365722e707567782e6f72672f4c656e6975732f6c61726176656c2d6261736b65742f762f737461626c65)](https://packagist.org/packages/Lenius/laravel-basket) [![License](https://camo.githubusercontent.com/eb5dd2e041733670700125c343fd704d5f6cea310407c5e473e9269e1703447f/68747470733a2f2f706f7365722e707567782e6f72672f4c656e6975732f6c61726176656c2d6261736b65742f6c6963656e7365)](https://packagist.org/packages/Lenius/laravel-basket)

Laravel Facade and Service Provider for Lenius\\Basket

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

[](#installation)

Using [composer](https://packagist.org/packages/lenius/laravel-basket):

```
$ composer require lenius/laravel-basket
$ composer require lenius/laravel-basket^4.0 (PHP7.4)
```

Set up demo with artisan

```
$ php artisan make:auth
$ php artisan make:ecommerce
```

Install npm dependencies

```
$ npm install v-money
$ npm install vue-sortable
$ npm install vuedraggable
$ npm run dev
$ php artisan serve
```

Open

You should then be good to go and be able to access the basket using the following static interface:

```
//Format array of required info for item to be added to basket...
$items = array(
	'id'       => 1,
	'name'     => 'Dog',
	'price'    => 120.00,
	'quantity' => 1,
	'weight'   => 200
);

//Make the insert...
Basket::insert(new Item($items));

//Let's see what we have got in their...
dd(Basket::totalItems());
```

### 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.

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

### Updating items in the Basket

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

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

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

### Removing Basket items

[](#removing-basket-items)

You can remove any items in your Basket by using the `remove()` method on any Basket item.

```
foreach (Basket::contents() as $item) {
    $item->remove();
}
```

### Destroying/emptying the Basket

[](#destroyingemptying-the-basket)

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

```
Basket::destroy()
```

### Retrieve the Basket contents

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

You can loop the Basket contents by using the following method

```
Basket::contents();
```

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

```
Basket::contents(true);
```

### Retrieving the total items in the Basket

[](#retrieving-the-total-items-in-the-basket)

```
Basket::totalItems();
```

By default this method will return all items in the Basket as well as their quantities. You can pass `true`as the first argument to get all unique items.

```
Basket::totalItems(true);
```

### Retrieving the Basket total

[](#retrieving-the-basket-total)

```
$Basket->total();
```

By default the `total()` method will return the total value of the Basket as a `float`, this will include any item taxes. If you want to retrieve the Basket total without tax then you can do so by passing false to the `total()` method

```
Basket::total(false);
```

### Check if the Basket has an item

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

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

### Retreive an item object by identifier

[](#retreive-an-item-object-by-identifier)

```
Basket::item($itemIdentifier);
```

Basket items
------------

[](#basket-items)

There are several features of the Basket items that may also help when integrating your Basket.

### Retrieving the total value of an item

[](#retrieving-the-total-value-of-an-item)

You can retrieve the total value of a specific Basket item (including quantities) using the following method.

```
Basket::total();
```

By default, this method will return the total value of the item plus tax. So if you had a product which costs 100, with a quantity of 2 and a tax rate of 20% then the total returned by this method would be 240.

You can also get the total minus tax by passing false to the `total()` method.

```
Basket::total(false);
```

This would return 200.

### Check if an item has options

[](#check-if-an-item-has-options)

You can check if a Basket item has options by using the `hasOptions()` method.

```
if ($item->hasOptions()) {
    // We have options
}
```

### Remove an item from the Basket

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

```
$item->remove();
```

### You can also get the total weight for a single item

[](#you-can-also-get-the-total-weight-for-a-single-item)

```
$item->weight();
```

### Output the item data as an array

[](#output-the-item-data-as-an-array)

```
$item->toArray();
```

###  Health Score

39

—

LowBetter than 85% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity33

Limited adoption so far

Community12

Small or concentrated contributor base

Maturity75

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 ~233 days

Recently: every ~212 days

Total

11

Last Release

2000d ago

Major Versions

v1.0.4 → v2.0.02017-10-11

v2.1.0 → v3.0.02019-01-25

v3.0.2 → v4.0.02021-01-06

PHP version history (3 changes)v1.0.0PHP &gt;=5.4.0

v1.0.1PHP &gt;=7.0.0

v4.0.0PHP ^7.4|^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 (66 commits)")

---

Tags

baskete-commercephpframeworklaravele-commerceLaravel Basketlenius

###  Code Quality

Static AnalysisPHPStan

Type Coverage Yes

### Embed Badge

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

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

###  Alternatives

[jsdecena/laracom

Laravel powered e-commerce

2.0k4.4k](/packages/jsdecena-laracom)[binafy/laravel-cart

Laravel Cart is a customizable package for adding shopping cart functionality to Laravel applications

40752.9k](/packages/binafy-laravel-cart)[hemp/presenter

Easy Model Presenters in Laravel

247608.3k1](/packages/hemp-presenter)[rahulalam31/laravel-abuse-ip

Block ip address of all spammer's around the world.

27234.5k](/packages/rahulalam31-laravel-abuse-ip)

PHPackages © 2026

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