PHPackages                             gabrielcabola/simple-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. [Utility &amp; Helpers](/categories/utility)
4. /
5. gabrielcabola/simple-shopping-cart

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

gabrielcabola/simple-shopping-cart
==================================

Simple Shopping Cart in PHP

19PHP

Since Dec 7Pushed 7y ago1 watchersCompare

[ Source](https://github.com/gabrielcabola/simple-shopping-cart)[ Packagist](https://packagist.org/packages/gabrielcabola/simple-shopping-cart)[ RSS](/packages/gabrielcabola-simple-shopping-cart/feed)WikiDiscussions master Synced yesterday

READMEChangelogDependenciesVersions (1)Used By (0)

[![alt text](https://github.com/gabrielcabola/simple-shopping-cart/raw/master/example/screen.png "sreenshot")](https://github.com/gabrielcabola/simple-shopping-cart/blob/master/example/screen.png)

Simple-shopping-cart
====================

[](#simple-shopping-cart)

A simple shopping cart class in PHP 5.4.x

How to use
----------

[](#how-to-use)

#### Load Class

[](#load-class)

```
//composer autoload (ignore if do you already have)
require '../vendor/autoload.php';
//load the class
use SSCart\Cart;
//Initialize
$cart = new Cart([array $options]);
```

### Options

[](#options)

ParameterTypeDescriptionprefix**string**Session name prefixAdd
===

[](#add)

```
// Add a product
$cart->add([object $product]);
```

ParameterTypeDescriptionid**string**Id of productname**string**title of productprice**float**Pricequantity**string**integer / default 1 if nullextra**array**Do you can pass extra information like color, size and othersChange quantity
===============

[](#change-quantity)

### More (up)

[](#more-up)

```
// Increase Item Quantity
$cart->upQuantity(id,amount);

//or use only to increase one
$cart->upQuantity(id);
```

### Less (down)

[](#less-down)

```
// Decrease Item Quantity
$cart->downQuantity(id,amount);

//or use only to decrease one
$cart->downQuantity(id);
```

Remove item
===========

[](#remove-item)

```
// Decrease Item Quantity
$cart->remove(id);
```

List all Itens
==============

[](#list-all-itens)

```
// List
$cart->items();
```

Total of products
=================

[](#total-of-products)

```
// Get a integer number of distinct products in cart
$cart->productsTotal();
```

Total of itens
==============

[](#total-of-itens)

```
// Get a integer number  of itens total in cart
$cart->itemsTotal();
```

Total Amount of Cart
====================

[](#total-amount-of-cart)

```
// Show total cost of cart
$cart->sumTotal()
```

Clear Cart
==========

[](#clear-cart)

```
// Cleat entire Cart
$cart->clearCart
```

Helpers
=======

[](#helpers)

### Using helpers

[](#using-helpers)

```
//Price sub class
use SSCart/Price;

//Format price and decimals
Price::format($number);

//Return Class currency ($ default)
Price::currency();
```

`Return a formated price.`

Example
=======

[](#example)

Run a simple app to demonstate how Cart works!

```
/example/index.php

```

###  Health Score

20

—

LowBetter than 14% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity6

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity39

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/1f139af325c0bead3689916ee0ece51d6c7899cc70e376de78c0045d018d86ff?d=identicon)[gabrielcabola](/maintainers/gabrielcabola)

---

Top Contributors

[![gabrielcabola](https://avatars.githubusercontent.com/u/1107828?v=4)](https://github.com/gabrielcabola "gabrielcabola (10 commits)")

### Embed Badge

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

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

###  Alternatives

[honeybee/honeybee

Library for implementing CQRS driven, event-sourced and distributed architectures.

222.1k4](/packages/honeybee-honeybee)[rami/seo-bundle

All in One Symfony Seo Bundle

321.0k](/packages/rami-seo-bundle)

PHPackages © 2026

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