PHPackages                             marshmallow/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. marshmallow/cart

ActiveLibrary

marshmallow/cart
================

Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.

5.0.0(9mo ago)46.4k↓33.3%[4 PRs](https://github.com/marshmallow-packages/ecommerce-cart/pulls)MITPHPPHP ^8.3CI passing

Since May 7Pushed 2mo ago1 watchersCompare

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

READMEChangelog (10)Dependencies (7)Versions (60)Used By (0)

[![alt text](https://camo.githubusercontent.com/f5450f299f5713ce2f04dd5a1ba7ce9960ed4568b3574e4c4ee3cddc75477253/68747470733a2f2f6d617273686d616c6c6f772e6465762f63646e2f6d656469612f6c6f676f2d7265642d3233377834362e706e67 "marshmallow.")](https://camo.githubusercontent.com/f5450f299f5713ce2f04dd5a1ba7ce9960ed4568b3574e4c4ee3cddc75477253/68747470733a2f2f6d617273686d616c6c6f772e6465762f63646e2f6d656469612f6c6f676f2d7265642d3233377834362e706e67)

Ecommerce Shopping Cart
=======================

[](#ecommerce-shopping-cart)

[![Version](https://camo.githubusercontent.com/e119fdc76e37c096109b4f91dfa0625c2add07f44afa2c55f39be70567bb6e1d/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6d617273686d616c6c6f772f63617274)](https://github.com/marshmallow-packages/ecommerce-cart)[![Issues](https://camo.githubusercontent.com/6d1fe6c1ccc681230ed9a894ae9f31f9e6cca0e8f01717f2f187922bfaafba03/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6973737565732f6d617273686d616c6c6f772d7061636b616765732f65636f6d6d657263652d63617274)](https://github.com/marshmallow-packages/ecommerce-cart)[![Licence](https://camo.githubusercontent.com/85f4a409b1113205bbb190a4bc0b4f2ea9859a01288d67a28313d434f43eb209/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f6d617273686d616c6c6f772d7061636b616765732f65636f6d6d657263652d63617274)](https://github.com/marshmallow-packages/ecommerce-cart)

This package contains all the logic you need to make use of a shopping cart in your Laravel application. It also contains all the Nova resources you need to manage your store. We use this package at Marshmallow for a lot of customers and add new functionalities when ever we need them. If you wish to use this, please do so and let us know if you have any issues.

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

[](#installation)

### Composer

[](#composer)

You can install this package via the following composer command.

```
composer require marshmallow/cart

```

### Migrate

[](#migrate)

You need to run the migration from this package to create all the tables we need to do some ecommerce magic.

```
php artisan migrate
```

### Middleware

[](#middleware)

Please add the following middle ware to your web group to make sure the cart is available on every route. If you wish to include this middleware to a select set of route you can do so.

```
protected $middlewareGroups = [
    'web' => [
        // ...
        \Marshmallow\Ecommerce\Cart\Http\Middleware\CartMiddleware::class,
    ],
];
```

### Nova

[](#nova)

Run the commands below to publish all the Nova resources that you need to manage all the ecommerce stuff.

```
php artisan marshmallow:resource Product Product
php artisan marshmallow:resource ProductCategory Product
php artisan marshmallow:resource Supplier Product
php artisan marshmallow:resource Price Priceable
php artisan marshmallow:resource VatRate Priceable
php artisan marshmallow:resource Currency Priceable
php artisan marshmallow:resource Prospect Ecommerce\\Cart
php artisan marshmallow:resource ShoppingCart Ecommerce\\Cart
php artisan marshmallow:resource Customer Ecommerce\\Cart
php artisan marshmallow:resource ShippingMethod Ecommerce\\Cart
php artisan marshmallow:resource ShippingMethodCondition Ecommerce\\Cart
php artisan marshmallow:resource Order Ecommerce\\Cart
php artisan marshmallow:resource OrderItem Ecommerce\\Cart
php artisan marshmallow:resource Discount Ecommerce\\Cart
php artisan marshmallow:resource Route Seoable
```

### Seed tables

[](#seed-tables)

We have created seeders for ecommerce site in the Netherlands. If you are running a dutch shop, you can run these seeders. If not, don't run these. Just create your own via the Nova resources you've just created.

```
php artisan db:seed --class=Marshmallow\\Priceable\\Seeders\\CurrencySeeder
php artisan db:seed --class=Marshmallow\\Priceable\\Seeders\\VatRatesSeeder
```

### Envoirment file

[](#envoirment-file)

Make sure you set the `CURRENCY` value in you `.env` file to match the currency you are using.

```
CURRENCY=eur
```

Events
------

[](#events)

This package triggers a set of events which you can listen to in your application if you wish to do so.

NameDescriptionCustomerCreatedThis will be triggered once a new customer has been created.OrderCreatedThis will be triggerd once a new order has been created.Discounts
=========

[](#discounts)

Setup
-----

[](#setup)

To use the discount module, you first need to make sure you have run all the `migrations`.

### Create the Nova resource

[](#create-the-nova-resource)

You need to publish the Nova resource to be able to create new discount code's in Nova. Run the command below.

```
php artisan marshmallow:resource Discount Ecommerce\\Cart
```

### Publish the new config

[](#publish-the-new-config)

There is a new config file that handles defaults for the discount functionalities. Run the command below to publish the new config file.

```
php artisan vendor:publish --tag="ecommerce-discount-config"
```

KeyDescriptionvoucher.min\_lengthThe minimum required length of a voucher codevoucher.exclude\_rulesThe exlusion rules for the code generatordefault.vat\_rateThe default `vat rate` we need to use for the discountdefault.currencyThe default `currency` we need to use for the discountUsage
-----

[](#usage)

### Adding a discount

[](#adding-a-discount)

To add the discount to a shopping cart, you need to create your own route/endpoint to handle this. You can use the example code below to active the discount. If all is oke, the `$response` will be empty. If something went wrong this method will return an error message containing the reason why we couldn't add the discount to the cart.

```
use Marshmallow\Ecommerce\Cart\Facades\Cart;
use Marshmallow\Ecommerce\Cart\Models\Discount;

$discount = Discount::byCode(
    request()->discount
);

$response = Cart::get()->addDiscount($discount);
```

### Deleting a discount

[](#deleting-a-discount)

If you made the customer to be able to delete an activated discount from the shopping cart, you will again have to create your own route/endpoint for this. You can then use the example code below to remove the discount from the card.

```
use Marshmallow\Ecommerce\Cart\Facades\Cart;

Cart::get()->deleteDiscount();
```

Cart methods
============

[](#cart-methods)

With the introduction of the discount methods you might need to update the methods that are used in your shopping cart to display cart totals. Please see the new methods below.

```
$cart->getTotalAmountWithoutShippingAndDiscount();
$cart->getTotalAmountWithoutShippingAndDiscountAndWithoutVat();
$cart->getDiscountAmount();
$cart->getDiscountAmountWithoutVat();
```

Cart methods
============

[](#cart-methods-1)

```
/**
 * These are helper functions to get cart totals.
 */
$cart->getTotalAmountWithoutShipping();
$cart->getTotalAmountWithoutShippingAndWithoutVat();
$cart->getShippingAmount();
$cart->getShippingAmountWithoutVat();
$cart->getTotalAmount();
$cart->getTotalAmountWithoutVat();
$cart->getTotalVatAmount();
$cart->getTotalAmountWithoutShippingAndDiscount();
$cart->getTotalAmountWithoutShippingAndDiscountAndWithoutVat();
$cart->getDiscountAmount();
$cart->getDiscountAmountWithoutVat();

/**
 * You can format all the methods above to get a string with currency.
 */
$cart->getFormatted('getTotalAmount');

/**
 * Extra helpers
 */
$cart->productCount();
$cart->getItemsWithoutShipping();
$cart->getItemsWithoutDiscount();
$cart->getDiscountItems();
$cart->getItemsWithoutDiscountAndShipping();
$cart->getOnlyProductItems();
```

Item methods
============

[](#item-methods)

```
$item->setQuantity(4);
$item->increaseQuantity();
$item->decreaseQuantity();

// Amount helpers
$item->getUnitAmount();
$item->getUnitAmountWithVat();
$item->getUnitAmountWithoutVat();
$item->getUnitVatAmount();
$item->getTotalAmount();
$item->getTotalAmountWithVat();
$item->getTotalAmountWithoutVat();
$item->getTotalVatAmount();

// Formatted
$item->getFormatted('getTotalAmount');
```

Changelog
---------

[](#changelog)

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

Testing
-------

[](#testing)

```
composer test
```

Security
--------

[](#security)

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

Credits
-------

[](#credits)

- [All Contributors](../../contributors)

License
-------

[](#license)

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

###  Health Score

52

—

FairBetter than 96% of packages

Maintenance73

Regular maintenance activity

Popularity26

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity81

Battle-tested with a long release history

 Bus Factor1

Top contributor holds 69.3% 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 ~31 days

Recently: every ~1 days

Total

51

Last Release

284d ago

Major Versions

v1.4.0 → v2.0.52022-10-13

v1.4.1 → v2.4.02023-10-18

v1.4.2 → v2.7.12025-08-01

v2.7.1 → v3.x-dev2025-08-01

v2.x-dev → 5.0.02025-08-07

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

v2.0.0PHP ^8.0

v3.x-devPHP ^8.3

### Community

Maintainers

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

---

Top Contributors

[![stefvanesch](https://avatars.githubusercontent.com/u/46725619?v=4)](https://github.com/stefvanesch "stefvanesch (201 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (62 commits)")[![LTKort](https://avatars.githubusercontent.com/u/2412670?v=4)](https://github.com/LTKort "LTKort (27 commits)")

---

Tags

marshmallow

### Embed Badge

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

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

PHPackages © 2026

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