Personal License $9.99

1 site, unlimited servers No source distribution Commercial use allowed Can modify source Read full license

You need to log-in or create an account
  • Create an account
  • Log-in
  • Please use your real name.
  • Account activation link will be sent to this address.
  • Minimum 8 characters

Clicking this button confirms you read and agreed to the terms of use and privacy policy.

Price: $ 9.99

View Pricing 14 days money-back guarantee

DevKen Cart Class

Cart class that works with wishlists, carts and recognizes products smartly.

Description

The DevKen Cart Class addresses an issue that I ran into several times while developing ecommerce websites. Customers wanted shopping carts that fit their needs exactly in design and aesthetics. I used a couple free versions for a few projects and found myself spending more time modifying them than I should have had to. So I decided to roll my own shopping cart class that would provide just what was required. It saved the list of products that users wanted to save and organized them in a way that makes it easy to display and calculate.

The Cart class handles any type of list that you need to manage. I also use it to maintain a history of products that users have visited and I use it to keep track of wishlists and download lists at the same time. It is very versatile and easy to integrate into any project. It is well documented and comes with a demo that works right out of the box. Just place it on your webserver and load it up.

Back to top

Example Usage

$cart = new Cart;       

// create a new item array - ID is required
$item = array('id'=>132,'qty'=>'1','color'=>'blue','size'=>'large');    
// Add item to cart
$cart->addItem($item);  

// Add two more items with the same ID (no overwrite)
$item['qty'] += 2;      
$cart->addItem($item);  

// Change the item color, a new item will be added this time
$item['color']  = 'white';  
$cart->addItem($item);  

// Remove item by index
$cart->removeItem(0);   

// Update item properties by index
$cart->updateItem(0,array('color'=>'yellow')); 

// Empty the cart
$cart->clearCart();     

// Dump the cart for debugging
$cart->dumpCart();      

// Get the cart for processing
$cartItems = $cart->getCart();      
foreach($cartItems as $item) {
      // Process cart 
}

Questions & Comments

No questions have been posted yet

Leave a comment

You must be logged-in to leave a comment.
Log-in now or register for a free account.
You must be logged-in to vote. Log-in to your account or register now.

User Reviews

No reviews have been submitted yet.

Price: $ 9.99

View Pricing 14 days money-back guarantee