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

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

simpavl/zf3-shoppingcart
========================

Simple ZF3 Shopping Cart

v1.0.1(10y ago)22031MITPHPPHP &gt;=5.3.0

Since Sep 12Pushed 9y ago2 watchersCompare

[ Source](https://github.com/simpavl/zf3-shoppingcart)[ Packagist](https://packagist.org/packages/simpavl/zf3-shoppingcart)[ Docs](https://github.com/martyshka/ShoppingCart)[ RSS](/packages/simpavl-zf3-shoppingcart/feed)WikiDiscussions master Synced 2w ago

READMEChangelog (1)Dependencies (1)Versions (3)Used By (0)

ShoppingCart
============

[](#shoppingcart)

This model is a simple ZF2 Shopping Cart solution. Provide basic functionality to create and modify Shopping Cart with any content in it. Easy to extend, just create your own Cart Entity and push it during Cart initialisation.

Inspired by
-----------

[](#inspired-by)

I was inspired to create the ShoppingCart by great job of Vincenzo Provenza and Concetto Vecchio (). Keeped the same idea behind but made it more flexible, easier to extend and simplier to change.

Zend Framework 3
----------------

[](#zend-framework-3)

This module was forked and repaired for zf3

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

[](#installation)

For the installation uses composer [composer](http://getcomposer.org "composer - package manager"). Add this project in your composer.json:

```
"require": {
    "simpavl/zf3-shoppingcart": "dev-master"
}

```

Post Installation
-----------------

[](#post-installation)

Configuration:

- Add the module of `config/application.config.php` under the array `modules`, insert `ShoppingCart`.
- Copy a file named `shoppingcart.global.php.dist` to `config/autoload/` and change name to `shoppingcart.global.php`.
- Modify config to fit your expectations.

Examples
========

[](#examples)

Insert
------

[](#insert)

You can insert as many items to the cart as you want. Each entry in cart will have unique token to work with. Example with one product:

```
$product = array(
    'id'      => 'XYZ',
    'qty'     => 1,
    'price'   => 15.15,
    'product' => 'Book: ZF2 for beginners',
);
$this->ShoppingCart()->insert($product);
```

Example with 2 products:

```
$products = array(
    array(
        'id'      => 'XYZ',
        'qty'     => 1,
        'price'   => 15.15,
        'product' => 'Book: ZF2 for beginners',
    ),
    array(
        'id'      => 'ZYX',
        'qty'     => 3,
        'price'   => 19.99,
        'product' => 'Book: ZF2 for advanced users',
    )
);
$this->ShoppingCart()->insert($products);
```

Remove
------

[](#remove)

```
$token => '4b848870240fd2e976ee59831b34314f7cfbb05b';
$this->ShoppingCart()->remove($token);
```

Destroy
-------

[](#destroy)

Erase Shopping Cart completely.

```
$this->ShoppingCart()->destroy();
```

Cart
----

[](#cart)

Get all content of Cart.

```
$this->ShoppingCart()->cart();
```

Total Sum
---------

[](#total-sum)

```
$this->ShoppingCart()->total_sum();
```

Total Items
-----------

[](#total-items)

```
$this->ShoppingCart()->total_items();
```

Example in controller
---------------------

[](#example-in-controller)

```
return new ViewModel(array(
    'cart' => $this->ShoppingCart()->cart(),
    'total_items' => $this->ShoppingCart()->total_items(),
    'total_sum' => $this->ShoppingCart()->total_sum(),
));
```

How to change/extend Shopping Cart
==================================

[](#how-to-changeextend-shopping-cart)

Provided Shopping Cart Entity is really basic one. You can change the structure of it. For example, if you need to add options to each item in the cart or to provide discount field and so on. What you should do:

- copy ShoppingCart/Entity/ShoppingCartEntity to your module
- modify YourModule/Entity/ShoppingCartEntity: add any fields you need to have
- during Shopping Cart initialisation provide your YourModule/Entity/ShoppingCartEntity

```
$this->ShoppingCart()->setEntityPrototype(new YourModule/Entity/ShoppingCartEntity());
```

FunctionsReference
------------------

[](#functionsreference)

  Function Description $this-&gt;ShoppingCart()-&gt;insert();Add item(s) to cart. $this-&gt;ShoppingCart()-&gt;remove();Delete the item from the cart. $this-&gt;ShoppingCart()-&gt;destroy();Delete all items from the cart. $this-&gt;ShoppingCart()-&gt;cart();Extracts all items from the cart. $this-&gt;ShoppingCart()-&gt;total\_sum();Counts the total sum of all items in the cart. $this-&gt;ShoppingCart()-&gt;total\_items();Counts the total number of all items in the cart.Contributors
============

[](#contributors)

Aleksander Cyrkulewski -

###  Health Score

29

—

LowBetter than 57% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity15

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity59

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

Total

2

Last Release

3670d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/9b1dc2a11fb64ca76ac66fbe3b34e9ab1f21adf1d60b091b834b183616e62f37?d=identicon)[Simpavl](/maintainers/Simpavl)

---

Top Contributors

[![martyshka](https://avatars.githubusercontent.com/u/1006739?v=4)](https://github.com/martyshka "martyshka (12 commits)")

---

Tags

zf2shopping cart

### Embed Badge

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

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

###  Alternatives

[slm/google-analytics

Google Analytics tracking integration for Zend Framework 2

4080.3k](/packages/slm-google-analytics)[cyrkulewski/shopping-cart

Simple ZF2 Shopping Cart

192.1k](/packages/cyrkulewski-shopping-cart)

PHPackages © 2026

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