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

ActiveLibrary[Framework](/categories/framework)

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 today

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

26

—

LowBetter than 41% of packages

Maintenance38

Infrequent updates — may be unmaintained

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

538d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/89684055?v=4)[Isuru Bandara](/maintainers/razorisuru)[@razorisuru](https://github.com/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

[laravel/horizon

Dashboard and code-driven configuration for Laravel queues.

4.2k95.4M306](/packages/laravel-horizon)[laravel/sail

Docker files for running a basic Laravel application.

1.9k205.7M1.3k](/packages/laravel-sail)[laravel/ai

The official AI SDK for Laravel.

1.0k3.2M194](/packages/laravel-ai)[laravel/mcp

Rapidly build MCP servers for your Laravel applications.

77022.3M151](/packages/laravel-mcp)[lukepolo/laracart

A simple cart for Laravel

585156.4k1](/packages/lukepolo-laracart)[laravel/surveyor

Static analysis tool for Laravel applications.

86121.4k11](/packages/laravel-surveyor)

PHPackages © 2026

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