PHPackages                             jason-napolitano/codeigniter4-cart-module - 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. jason-napolitano/codeigniter4-cart-module

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

jason-napolitano/codeigniter4-cart-module
=========================================

A basic port of the codeigniter 3 cart module for CodeIgniter 4.

1.1.0(5y ago)5814.8k↓35%28MITPHP

Since May 28Pushed 1y ago7 watchersCompare

[ Source](https://github.com/jason-napolitano/CodeIgniter4-Cart-Module)[ Packagist](https://packagist.org/packages/jason-napolitano/codeigniter4-cart-module)[ Docs](https://github.com/jason-napolitano/CodeIgniter4-Cart-Module)[ RSS](/packages/jason-napolitano-codeigniter4-cart-module/feed)WikiDiscussions master Synced 1mo ago

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

CodeIgniter4-Cart-Module
========================

[](#codeigniter4-cart-module)

> This is a `composer` installable, CodeIgniter 4 module that is nearly a direct port of the Codeigniter 3 Cart Library Class. Of course, this has been mildly updated and is consistent with the new version of the framework.
>
> This means that instead of just being a *class* that you can use in your projects, this library has been updated with Namespaces, has been refactored to adhere to the CodeIgniter style guide and also has been built to use CodeIgniter 4's Service Container to allow for a shared Cart instance across your application.
>
> More detailed documentation can be found [here](https://codeigniter.com/userguide3/libraries/cart.html). Please note that the documentation is for the CodeIgniter 3 library but the fundamentals and inner workings of the library are still identical. The most notable changes are how you use it (read below) and to return the total items in your cart, you now call `$cart->totalItems()` instead of `$this->cart->total_items()`.
>
> Please take note that there are no tests for this package, nor is it officially supported since it is just a port from an existing Codeigniter library and works exactly the same.

Installation:
-------------

[](#installation)

- Install via composer `composer require jason-napolitano/codeigniter4-cart-module`
- Add it to the `$psr4` array in `app/Config/Autoload.php`:

```
$psr4 = [
   'CodeIgniterCart' => ROOTPATH . 'vendor/jason-napolitano/codeigniter4-cart-module/src'

   // OTHER PSR4 ENTRIES
];
```

Usage
-----

[](#usage)

```
// Call the cart service
$cart = \Config\Services::cart();

// Insert an array of values
$cart->insert(array(
   'id'      => 'sku_1234ABCD',
   'qty'     => 1,
   'price'   => '19.56',
   'name'    => 'T-Shirt',
   'options' => array('Size' => 'L', 'Color' => 'Red')
));

// Update an array of values
$cart->update(array(
   'rowid'   => '4166b0e7fc8446e81e16883e9a812db8',
   'id'      => 'sku_1234ABCD',
   'qty'     => 3,
   'price'   => '24.89',
   'name'    => 'T-Shirt',
   'options' => array('Size' => 'L', 'Color' => 'Red')
));

// Get the total items. Formerly known as total_items()
$cart->totalItems();

// Remove an item using its `rowid`
$cart->remove('4166b0e7fc8446e81e16883e9a812db8');

// Clear the shopping cart
$cart->destroy();

// Get the cart contents as an array
$cart->contents();
```

License:
--------

[](#license)

MIT License

Copyright (c) 2025 Jason Napolitano

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

###  Health Score

40

—

FairBetter than 88% of packages

Maintenance34

Infrequent updates — may be unmaintained

Popularity40

Moderate usage in the ecosystem

Community17

Small or concentrated contributor base

Maturity57

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 98.6% 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 ~178 days

Total

2

Last Release

2003d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/8c3ea013ad87d98d3420184d0ecb9425035e80eb3e3e3f7b34cb81600c9512b8?d=identicon)[jason-napolitano](/maintainers/jason-napolitano)

---

Top Contributors

[![jason-napolitano](https://avatars.githubusercontent.com/u/16026431?v=4)](https://github.com/jason-napolitano "jason-napolitano (72 commits)")[![danieliheonu](https://avatars.githubusercontent.com/u/64360587?v=4)](https://github.com/danieliheonu "danieliheonu (1 commits)")

---

Tags

cartcodeignitercodeigniter4librarymodulephpshopping-cart

### Embed Badge

![Health badge](/badges/jason-napolitano-codeigniter4-cart-module/health.svg)

```
[![Health](https://phpackages.com/badges/jason-napolitano-codeigniter4-cart-module/health.svg)](https://phpackages.com/packages/jason-napolitano-codeigniter4-cart-module)
```

###  Alternatives

[hermawan/codeigniter4-datatables

Serverside Datatables library for CodeIgniter4

10943.0k3](/packages/hermawan-codeigniter4-datatables)

PHPackages © 2026

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