| Last Updated |   | Ratings |   | Unique User Downloads |   | Download Rankings | 
2025-06-04 (3 hours ago)   |  | Not enough user ratings |  | Total: 427  |  | All time:  6,344 This week: 33  | 
 | 
| Description |   | Author  | 
This class can manage a shopping cart stored in session variables. 
 
It can perform several types of operations to manipulate the contents of a shopping cart. 
 
Currently it can insert new items, update cart items, save the cart items to a session variable, remove items, destroy the whole shopping cart, and retrieve the list of items.  |  | 
 
  | 
Recommendations
Details
ShoppingCartLibraryv1.0
A simple, extensible PHP class for integrating a shopping cart into your web applications. This library was developed at the University Institute of Information Technology (UIIT-UAAR) and is released under the GPL license.
Features
- 
Add items to cart
 
- 
Delete items from cart
 
- 
Update items in cart
 
- 
Save cart in session
 
- 
Display all items in cart (in reverse order)
 
- 
Destroy the cart (usually after placing an order)
 
- 
Calculate total amount and total items
 
Getting Started
Requirements
- 
PHP 5.3 or later
 
- 
Sessions enabled in your PHP environment
 
Installation
- 
Clone or download this repository.
 
- 
Include the `Cart.php` file in your project:
require_once 'Cart.php';
 
- 
Start a PHP session at the beginning of your script if not already started:
session_start();
 
Usage
Initialize the Cart
$cart = new Cart();
Add an Item
$item = array(
    'id' => 1,
    'name' => 'Product Name',
    'quantity' => 2,
    'price' => 100
    // 'options' => array('size' => 'L', 'color' => 'red') // Optional
);
$cart->insert($item);
Update an Item
$cart->update(array(
    'rowid' => $rowid, // Obtain rowid from cart contents
    'quantity' => 3
));
Remove an Item
$cart->remove($rowid);
Get Cart Contents
$items = $cart->contents();
Get Cart Total
$total = $cart->total();
Destroy the Cart
$cart->destroy();
Example
See index.php for a basic usage example.
License
This project is licensed under the GPL License. See the LICENSE file for details.
Author
Ahmed Rehan  
University Institute of Information Technology (UIIT-UAAR)
This library is intended for educational purposes and basic PHP shopping cart integration. Contributions and improvements are welcome!
 
 
|   | 
Applications that use this package | 
  | 
No pages of applications that use this class were specified.
 If you know an application of this package, send a message to the author to add a link here.