anam-hossain / phpcart by anam

Simple framework agnostic shopping cart
Package Data
Maintainer Username: anam
Maintainer Contact: (Anam hossain)
Package Create Date: 2015-01-29
Package Last Update: 2020-07-16
Home Page:
Language: PHP
License: MIT
Last Refreshed: 2024-05-15 15:13:51
Package Statistics
Total Downloads: 14,921
Monthly Downloads: 32
Daily Downloads: 1
Total Stars: 122
Total Watchers: 15
Total Forks: 31
Total Open Issues: 3


Simple framework agnostic shopping cart.


  • Simple API
  • Support multiple cart instances
  • Framework agnostic


  • PHP 5.4+


PHPCart is available via Composer

$ composer require anam/phpcart

Laravel Integrations

Use the following dedicated laravel package for PHPCart.


Add Item

The add method required id, name, price and quantity keys. However, you can pass any data that your application required.

use Anam\Phpcart\Cart;

$cart = new Cart();

    'id'       => 1001,
    'name'     => 'Skinny Jeans',
    'quantity' => 1,
    'price'    => 90

Update Item

    'id'       => 1001,
    'name'     => 'Hoodie'

Update quantity

$cart->updateQty(1001, 3);

Update price

$cart->updatePrice(1001, 30);

Remove an Item


Get all Items

// or

Get an Item


Determining if an Item exists in the cart


Get the total number of items in the cart


Get the total quantities of items in the cart


Total sum


Empty the cart


Multiple carts

PHPCart supports multiple cart instances, so that you can have as many shopping cart instances on the same page as you want without any conflicts.

$cart = new Cart('cart1');
// or
    'id'       => 1001,
    'name'     => 'Skinny Jeans',
    'quantity' => 1,
    'price'    => 90

    'id'       => 1001,
    'name'     => 'Jeans',
    'quantity' => 2,
    'price'    => 100