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

ActiveLibrary[Framework](/categories/framework)

kbcart/zf3-kbcart
=================

Practical Simple ZF3 Shopping Cart

0.0.1(7y ago)0221MITPHPPHP &gt;=5.6

Since Jun 19Pushed 7y ago1 watchersCompare

[ Source](https://github.com/KianWilliam/ZF3KbCart)[ Packagist](https://packagist.org/packages/kbcart/zf3-kbcart)[ Docs](https://github.com/KianWilliam/ZF3KbCart)[ RSS](/packages/kbcart-zf3-kbcart/feed)WikiDiscussions master Synced 2mo ago

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

ZF3KbCart
=========

[](#zf3kbcart)

simple shopping cart for zend frame work 3 KbCart
=================================================

[](#simple-shopping-cart-for-zend-frame-work-3kbcart)

A Simple shopping cart for zf3. Based on the information provided by routes in your website, use the functionality of it. I did not use hydrator in this version just simple array to array with no stuff attached. I got the basic idea from Aleksander Cyrkulewski who used hydrator, I used zend-config xml file creation and delete and collect the stuff in an array, obtaining data directly from array, here the user could specify as many as subcategories needed by following my way and reflech it in shopping cart view of her/his website. Do not forget you need zend-config and zend-crypt to use this module.

Zend Framework 2 and 3
----------------------

[](#zend-framework-2-and-3)

This module could be used both in zf2 and zf3

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

[](#installation)

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

```
"require": {
    "kbcart/zf3-kbcart": "@dev"
}

```

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

[](#post-installation)

Configuration:

- Add the module of `config/application.config.php` under the array `modules`, insert `kbcart`.
- Copy a file named `kbcart.global.php` to `config/autoload/`.
- You may change this file based on your application parameters.

Examples
========

[](#examples)

Before showing examples, few explanations could be to your benefit: Supposing you have a store, each item is located in a page, clicking on it directs your customer to detailed page for that item with the help of its route. the customer selects the item with the required quantity, all reflected in route. To have category and subcategorie(s), this data must be reflected as an option or param in route (directly or via getting breadcrumb) then fixing the param option in route for that form. The protocol must be like this: $this-&gt;url('routename', \[\], \['query'=&gt;\['category':'category-subcategory-...'\]\]). In related action controller: $this-&gt;kbcart();

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. In related controller include: use Zend\\Config\\Config; use Zend\\Config\\Writer\\Xml;

in controller action:

$kbcart = $this-&gt;kbcart();

```
 $config = new Config([], true);
 GET $category from query as explained above. e.g:
 $category='books-physic-newton';
 $config->$category=[];
 you MUST do exactly according below, the same order and words:
 the values below is obtained by route, remember no money sign like Euro or dollar sign for price, just float numbers.
 $config->$category->itemid="1";
 $config->$category->name="principa";
 $config->$category->price="19.19";
 $config->$category->quantity="1";

 $writer = new Xml();

 a temporary file will be created, if two or more users apply for the same item at the same time,
 randome functions prevent from being created the same file for different customers.

  srand(time());
  $num=rand(1, 1000);

 $writer->toFile(__DIR__.'/../kbcart_'.$num.'.xml',$config);
 $kbcart->insert(__DIR__.'/../kbcart_'.$num.'.xml');

 The created file shall be deleted automatically after insert into your cart.
 Also you can use var_dump($this->kbcart()->cart) to check the content of basket.

```

Remove
------

[](#remove)

```
In cart view template page, when you assign the session array to the form(s) route there, token will be assigned
as a param or query and could be obtained from route.
$token : '4b848870240fd2e976ee59831b34314f7cfbb05b';
$this->kbcart()->remove($token);
```

Update
------

[](#update)

```
In cart view template page, when you assign the session array to the form(s) route there, token will be assigned
as a param or query and could be obtained from route.
$token : '4b848870240fd2e976ee59831b34314f7cfbb05b';
$this->kbcart()->update($token, $amount);
```

Destroy
-------

[](#destroy)

Erase Kb Cart completely.

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

Cart
----

[](#cart)

View all contents of cart:

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

Total Sum
---------

[](#total-sum)

```
In each update, insert or delete of an item shall be calculated automatically,
to view it: $kbcart = $this->kbcart()->cart();
echo $kbcart['cartval'];
```

To pass the cart to view template
---------------------------------

[](#to-pass-the-cart-to-view-template)

```
return new ViewModel(['cart'=>$this->kbcart()->cart()]);

```

KbCart
======

[](#kbcart)

The provided cart is quite practical, having the itemid, all data to that item is accessible from database or file no need to make cart more complex with other options like discount , ... So the simpler the more practical. For insert: In action controller first check the cart and its items. suppose the customer selected the same item two different times if not, then insert should be used.

Main Functions
--------------

[](#main-functions)

  Function Description $this-&gt;kbcart()-&gt;insert();Add item(s) to cart. $this-&gt;kbcart()-&gt;remove();Delete the item from the cart. $this-&gt;kbcart()-&gt;destroy();Delete all items from the cart. $this-&gt;kbcart()-&gt;cart();Extracts all items from the cart. $this-&gt;kbcart()-&gt;cartTotalPrice();Counts the total sum of all items in the cart. $this-&gt;kbcart()-&gt;update();to update the quantity for an item.Developed by
============

[](#developed-by)

Kian William Nowrouzian -

###  Health Score

22

—

LowBetter than 22% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity7

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity47

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

Unknown

Total

1

Last Release

2884d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/6cce69529166eae4d465a7ae5864e67e3161a3c93594acf7511a2109235ca6e3?d=identicon)[KianWilliam](/maintainers/KianWilliam)

---

Top Contributors

[![KianWilliam](https://avatars.githubusercontent.com/u/15556940?v=4)](https://github.com/KianWilliam "KianWilliam (20 commits)")

---

Tags

cartshopping cartzf3store cart

### Embed Badge

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

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

###  Alternatives

[darryldecode/cart

Laravel 5 Shopping cart

1.4k1.7M7](/packages/darryldecode-cart)[lukepolo/laracart

A simple cart for Laravel

583135.4k1](/packages/lukepolo-laracart)[anam/phpcart

Simple framework agnostic shopping cart

12115.4k](/packages/anam-phpcart)[agungsugiarto/codeigniter4-shoppingcart

CodeIgniter4 shopping cart.

201.5k](/packages/agungsugiarto-codeigniter4-shoppingcart)

PHPackages © 2026

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