PHPackages                             bni/shoppingcart - 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. bni/shoppingcart

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

bni/shoppingcart
================

Shopping Cart Helper for your PHP Project

01PHP

Since Oct 6Pushed 6y ago1 watchersCompare

[ Source](https://github.com/BelajarNgewebID/shoppingcart)[ Packagist](https://packagist.org/packages/bni/shoppingcart)[ RSS](/packages/bni-shoppingcart/feed)WikiDiscussions master Synced 2mo ago

READMEChangelogDependenciesVersions (2)Used By (0)

Shopping Cart Helper
====================

[](#shopping-cart-helper)

No worries about your online shop. Just use this to store temporary shopping cart data

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

[](#installation)

---

```
composer require bni/shoppingcart

```

Cart Usage
----------

[](#cart-usage)

---

### Base Structure

[](#base-structure)

```
[{
    "id": 1,
    "name": "Cart name",
    "items": []
}]

```

### Get All Carts

[](#get-all-carts)

```
$cart = Cart::get();

```

### Get Cart with condition

[](#get-cart-with-condition)

```
$cart = Cart::where(['id' => 1])->get();
// or
$cart = Cart::where(['name' => 'My cart'])->get();

```

### Create New Cart

[](#create-new-cart)

```
$cart = Cart::add([
    'name' => 'Shopping Cart Name'
]);

```

### Edit Cart

[](#edit-cart)

```
$cart = Cart::where(['id' => 1])->update([
    'name' => 'New Cart name'
]);

```

### Delete cart

[](#delete-cart)

```
$cart = Cart::where(['id' => 1])->delete();

```

Items usage
-----------

[](#items-usage)

---

### Base Structure

[](#base-structure-1)

```
[{
    ...
    "items": [
        {
            "id": 1,
            "title": "Product name",
            "attributes": {
                "weight": 250
            }
        }
    ]
}]

```

*You can add your own attributes*

### Get all items

[](#get-all-items)

```
$item = Cart::where(['id' => 1])->item()->get();

```

### Get current item

[](#get-current-item)

```
$item = Cart::where(['id' => 1])->item(['id' => 2])->get();

```

*item() parameter like where(), you can use id or name*

### Add new item

[](#add-new-item)

```
$item = Cart::where(['id' => 1])->item()->add([
    'title' => 'Your product item',
    'attributes' => [
        'weight' => 250
    ]
]);

```

### Delete item

[](#delete-item)

```
$item = Cart::where(['id' => 1])->item(['id' => 2])->delete();

```

### Edit item

[](#edit-item)

```
$item = Cart::where(['id' => 1])->item(['id' => 2])->update([
    'title' => 'Edited product'
]);

```

###  Health Score

17

—

LowBetter than 6% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity1

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity37

Early-stage or recently created project

 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.

### Community

Maintainers

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

---

Top Contributors

[![BelajarNgewebID](https://avatars.githubusercontent.com/u/23579333?v=4)](https://github.com/BelajarNgewebID "BelajarNgewebID (1 commits)")

### Embed Badge

![Health badge](/badges/bni-shoppingcart/health.svg)

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

###  Alternatives

[mascame/arrayer

Array manipulation with dot notation. Also prepares an array to be put in a file. Very useful for config files.

141.4k2](/packages/mascame-arrayer)

PHPackages © 2026

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