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

ActiveLibrary[Framework](/categories/framework)

itemvirtual/ecommerce-cart
==========================

Shopping cart in Laravel

1.0.1(1y ago)170MITPHPPHP ^7.4|^8.0

Since Jul 20Pushed 1y ago2 watchersCompare

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

READMEChangelog (4)Dependencies (2)Versions (6)Used By (0)

Ecommerce Cart
==============

[](#ecommerce-cart)

[![Latest Version on Packagist](https://camo.githubusercontent.com/2a390a97a4a8cdfe67eb93ddc8a6c2527156f23ffec6739899cea26c0a3e9e70/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6974656d7669727475616c2f65636f6d6d657263652d636172742e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/itemvirtual/ecommerce-cart)[![Total Downloads](https://camo.githubusercontent.com/348d84c39366907990d8552cff654603354c6d38f7dc48858ccb91b0d9e5c5dd/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6974656d7669727475616c2f65636f6d6d657263652d636172742e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/itemvirtual/ecommerce-cart)

This is where your description should go. Try and limit it to a paragraph or two, and maybe throw in a mention of what PSRs you support to avoid any confusion with users and contributors.

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

[](#installation)

Install the package via composer:

```
composer require itemvirtual/ecommerce-cart
```

Publish config (with `--force` option to update)

```
php artisan vendor:publish --provider="Itemvirtual\EcommerceCart\EcommerceCartServiceProvider" --tag=config
```

You can change the `config` values for `cart_session_name` and `taxes_included`:

```
#ECOMMERCE_CART_SESSION_NAME="ecommerceCart"
ECOMMERCE_TAXES_INCLUDED=true
ECOMMERCE_CALCULATE_TOTALS=true
```

Add `EcommerceCart` to your `config/app` aliases array

```
'EcommerceCart' => Itemvirtual\EcommerceCart\Facades\EcommerceCart::class,
```

Usage
-----

[](#usage)

Use the `EcommerceCart` Facade

```
use Itemvirtual\EcommerceCart\Facades\EcommerceCart;
```

#### Add products to cart

[](#add-products-to-cart)

```
EcommerceCart::addToCart([
    'id' => $Product->id,
    'title' => $Product->name,
    'price' => floatval($Product->price),
    'tax' => 21.0,
    'amount' => 1,
    'data' => [ // add your custom data here
        'tax_id' => 1
    ]
]);
```

#### Increment or decrement amount

[](#increment-or-decrement-amount)

```
EcommerceCart::incrementCartItem($Product->id);
EcommerceCart::decrementCartItem($Product->id);
```

#### Remove from cart

[](#remove-from-cart)

```
EcommerceCart::removeCartItem($Product->id);
```

#### Set tax

[](#set-tax)

```
EcommerceCart::setTax($float);
```

The tax value is set for each item in the cart. To set a global tax value, use `setCustomCartData()`
It will not affect the calculation of totals on the cartItem, It only serves as data to calculate your totals.

```
EcommerceCart::setCustomCartData('tax', floatval($tax));
```

If you save the tax\_id value, you can change it with `updateCartItemsDataValue()`

```
EcommerceCart::updateCartItemsDataValue($key, $value);
// EcommerceCart::updateCartItemsDataValue('tax_id', 1);
```

#### Set apply tax (p.ex if not European)

[](#set-apply-tax-pex-if-not-european)

```
EcommerceCart::setApplyTax($boolean);
```

Get Totals
----------

[](#get-totals)

### Custom Total calculations

[](#custom-total-calculations)

If you need to calculate your Cart Totals, set `ECOMMERCE_CALCULATE_TOTALS` to `false` in your `.env` file

```
ECOMMERCE_CALCULATE_TOTALS=false
```

Create your service and use `EcommerceCart::getItems()` to get your cart contents

```
$cartItems = EcommerceCart::getItems();
```

### Total calculations

[](#total-calculations)

```
EcommerceCart::getTotal();
EcommerceCart::getSubtotal();
// return taxes array
EcommerceCart::getTaxTotals();
// return total tax amount
EcommerceCart::getTaxTotalValue();

// Get total without shipping
EcommerceCart::getTotalWithoutShipping();
```

#### Shipping

[](#shipping)

Add Global shipping

```
$ShippingData = [
    'id' => $Shipping->id,
    'title' => $Shipping->title,
    'value' => $Shipping->value,
    'free_from' => $Shipping->free_from,
];
EcommerceCart::setShipping($ShippingData);
```

Remove Shipping data

```
EcommerceCart::removeShipping();
```

Get Shipping data

```
EcommerceCart::getShipping();

// Returns an object with 4 or 5 properties
{
  +"id": 3
  +"title": "Europe"
  +"value": 10
  +"free_from": 200
  +"free": true
}
```

#### Get Cart Items

[](#get-cart-items)

```
$cartItems = EcommerceCart::getItems();

EcommerceCart::hasItems();
EcommerceCart::countItems();
```

#### Destroy Cart

[](#destroy-cart)

```
EcommerceCart::destroyCart();
```

### Testing

[](#testing)

```
composer test
```

### Changelog

[](#changelog)

Please see [CHANGELOG](CHANGELOG.md) for more information what has changed recently.

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

[](#contributing)

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

Credits
-------

[](#credits)

- [Sergio](https://github.com/sergio-item)
- [Itemvirtual](https://github.com/itemvirtual)
- [All Contributors](../../contributors)

License
-------

[](#license)

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

###  Health Score

29

—

LowBetter than 60% of packages

Maintenance33

Infrequent updates — may be unmaintained

Popularity10

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity56

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

Every ~178 days

Total

5

Last Release

676d ago

Major Versions

v0.x-dev → 1.0.02024-07-01

### Community

Maintainers

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

---

Top Contributors

[![sergio-item](https://avatars.githubusercontent.com/u/10372524?v=4)](https://github.com/sergio-item "sergio-item (25 commits)")

---

Tags

itemvirtualecommerce-cart

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/itemvirtual-ecommerce-cart/health.svg)

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

###  Alternatives

[laravel/telescope

An elegant debug assistant for the Laravel framework.

5.2k67.8M190](/packages/laravel-telescope)[spiral/roadrunner

RoadRunner: High-performance PHP application server and process manager written in Go and powered with plugins

8.4k12.2M84](/packages/spiral-roadrunner)[nolimits4web/swiper

Most modern mobile touch slider and framework with hardware accelerated transitions

41.8k177.2k1](/packages/nolimits4web-swiper)[laravel/dusk

Laravel Dusk provides simple end-to-end testing and browser automation.

1.9k36.7M256](/packages/laravel-dusk)[laravel/prompts

Add beautiful and user-friendly forms to your command-line applications.

708181.8M591](/packages/laravel-prompts)[cakephp/chronos

A simple API extension for DateTime.

1.4k47.7M121](/packages/cakephp-chronos)

PHPackages © 2026

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