PHPackages                             haska/laravel-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. [Utility &amp; Helpers](/categories/utility)
4. /
5. haska/laravel-cart

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

haska/laravel-cart
==================

Laravel cart package

3142PHP

Since May 25Pushed 11y ago2 watchersCompare

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

READMEChangelogDependenciesVersions (1)Used By (0)

Laravel cart package
====================

[](#laravel-cart-package)

Informations
------------

[](#informations)

Provider:

```
'Haska\Cart\CartServiceProvider',
```

Alias:

```
'Cart' => 'Haska\Cart\Facade',
```

Config:

```
php artisan config:publish haska:laravel-cart
```

Examples:

### Insert

[](#insert)

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

// Make the insert...
Cart::insert($items);
```

### Insert with tax rate (in this example 20%)

[](#insert-with-tax-rate-in-this-example-20)

```
Cart::insert(array(
    'id'       => 'foo',
    'name'     => 'bar',
    'price'    => 100,
    'quantity' => 1,
    'tax'      => 20
));
```

### Updating items in the cart

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

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

### Removing items in the cart

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

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

### Destroying/emptying the cart

[](#destroyingemptying-the-cart)

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

### Retrieve the cart contents

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

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

Content passed like an array

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

### Retrieving the total items in the cart

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

```
Cart::totalItems();
```

Get only unique items

```
Cart::totalItems(true);
```

### Retrieving the cart total

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

```
Cart::total();
```

Passed without tax rates

```
Cart::total(false);
```

### Check if the cart has an item

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

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

### Retreive an item object by identifier

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

```
$item = Cart::item($id);
```

Cart items (item objects)
-------------------------

[](#cart-items-item-objects)

### Retrieving the total value of an item

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

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

Without tax rates

```
$item->total(false);
```

### Check if an item has options

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

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

### Remove an item from the cart

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

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

### Output the item data as an array

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

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

###  Health Score

22

—

LowBetter than 22% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity11

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity41

Maturing project, gaining track record

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.

### Community

Maintainers

![](https://www.gravatar.com/avatar/5c352a3ff067ddeaa19a4825a48044ba5f2932a77ae3455e3f765c034b569451?d=identicon)[haska](/maintainers/haska)

### Embed Badge

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

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

PHPackages © 2026

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