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

ActiveLibrary

razorisuru/shopping-cart
========================

The ShoppingCart package provides a simple and flexible solution for managing a shopping cart in Laravel applications. It uses sessions to store cart items, allowing you to easily add, update, remove, and clear items. With support for custom attributes, price calculations, and total cost computation, this package is ideal for building e-commerce and order management systems.

1.0.3(1y ago)110MITPHPPHP ^8.0

Since Jan 10Pushed 1y ago1 watchersCompare

[ Source](https://github.com/razorisuru/shopping-cart)[ Packagist](https://packagist.org/packages/razorisuru/shopping-cart)[ RSS](/packages/razorisuru-shopping-cart/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (4)Dependencies (1)Versions (5)Used By (0)

ShoppingCart for Laravel
========================

[](#shoppingcart-for-laravel)

**ShoppingCart** is a simple and lightweight package for managing a shopping cart in Laravel applications using sessions. This package is ideal for e-commerce platforms or any project requiring shopping cart functionality.

---

Features
--------

[](#features)

- Add items to the cart with quantity, price, and custom attributes.
- Update or remove items from the cart.
- Calculate the total cost of items in the cart.
- Clear all items in the cart.
- Session-based for seamless integration.

---

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

[](#installation)

1. Clone the repository:

    ```
    composer require razorisuru/shopping-cart
    ```
2. Configure Composer to use the token (Optional):

    ```
    composer config --global github-oauth.github.com your-personal-access-token
    ```

Usage

Declare the cart:

```
use razorisuru\ShoppingCart\Cart;

class ProductController extends Controller
{
   protected $cart;

   public function __construct()
   {
      $this->cart = new Cart(); // Initialize an instance of the Cart class
   }
}
```

1. Adding Items to the Cart:

    ```
    $this->cart->add($userId = 1, $itemId = 101, $quantity = 2, $price = 10.50, $attributes = ['color' => 'red']);
    ```
2. Getting All Cart Items:

    ```
    $this->items = $cart->getAll($userId = 1);
    ```
3. Updating an Item's Quantity:

    ```
    $this->cart->update(1, 1, 5); // Update item with USERID 1, PRODUCTID 1 to have a quantity of 5
    ```
4. Removing an Item:

    ```
    $this->cart->remove($userId = 1, $itemId = 101);
    ```
5. Clearing the Cart:

    ```
    $this->cart->clear($userId = 1);
    ```
6. Calculating Total Cost:

    ```
    $this->cart->total($userId = 1);
    ```
7. Counting the user cart items:

    ```
    $this->cart->countQuantity($userId = 1);
    ```
8. Counting the user cart Product Count:

    ```
    $this->cart->countProducts($userId = 1);
    ```

Requirements PHP 8.0 or newer Laravel 8 or newer illuminate/support

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

[](#contributing)

Contributions are welcome! To contribute:

1. Fork the repository.
2. Create a feature branch: `git checkout -b feature-name`.
3. Commit your changes: `git commit -m 'Add some feature'`.
4. Push to the branch: `git push origin feature-name`.
5. Open a pull request.

License
-------

[](#license)

This project is open-sourced software licensed under the [MIT license](LICENSE).

###  Health Score

27

—

LowBetter than 49% of packages

Maintenance42

Moderate activity, may be stable

Popularity7

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity46

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

Total

4

Last Release

485d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/7c9aec35c52201a881c79b2f048b117445276806a509c18e65b2ff62b0df2aef?d=identicon)[razorisuru](/maintainers/razorisuru)

---

Top Contributors

[![razorisuru](https://avatars.githubusercontent.com/u/89684055?v=4)](https://github.com/razorisuru "razorisuru (23 commits)")

---

Tags

laravelusersessioncartshoppingrazorisuru

### Embed Badge

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

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

###  Alternatives

[spatie/laravel-activitylog

A very simple activity logger to monitor the users of your website or application

5.8k45.4M309](/packages/spatie-laravel-activitylog)[lukepolo/laracart

A simple cart for Laravel

583135.4k1](/packages/lukepolo-laracart)[amsgames/laravel-shop

Package set to provide shop or e-commerce functionality (such as CART, ORDERS, TRANSACTIONS and ITEMS) to Laravel for customizable builds.

4845.9k](/packages/amsgames-laravel-shop)[yabhq/laravel-cart

Simple yet customizable Laravel shopping cart

213.0k](/packages/yabhq-laravel-cart)[syscover/shopping-cart

Shopping Cart package

299.1k1](/packages/syscover-shopping-cart)

PHPackages © 2026

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