web developer's note
Posts tagged cart library
Shopping Cart using Codeigniter 1.7.2 Cart Library [part-2]
Nov 25th
After you succed create product listing page on the previous post now this is real action now, Next step we create cart controller, this controller contain important method which will provide some action in shopping cart. Those methode are add(), view_cart(), update(), delete(), etc. Let’s take a look to this code.
Shopping Cart using Codeigniter 1.7.2 Cart Library [part-1]
Nov 23rd
There are some improvements and additional changes in Codeigniter 1.7.2, one of them is shopping cart library (system/libraries/Cart.php). This class provide simple shopping cart functionality such as add to cart, view cart, and update/delete cart. With this library we can count item on cart, sub total, and total price items. To learn how to use it in codeigniter user guide , on library section. Although in user guide is complete enough explanation for some users, in this article i try to implement shopping cart using Codeigniter 1.7.2 Shopping Cart library.
Let’s do some preparation such as create new application from codeigniter source directory, create sample database with one simple table (name it product). In this article i will create some files, two controller (products, and cart), four view files (shopping home, view_cart, header, and footer). I think we don’t have to create model because we just review shopping cart functionality.
First create database containt product table like this:
CREATE TABLE IF NOT EXISTS `product` ( `product_id` int(10) NOT NULL AUTO_INCREMENT, `product_sku` varchar(16) NOT NULL, `product_name` varchar(32) NOT NULL, `product_description` varchar(200) NOT NULL, `product_quantity` double(10,4) NOT NULL, `product_price` double(10,2) NOT NULL, `product_imgpath` varchar(128) NOT NULL, PRIMARY KEY (`product_id`), UNIQUE KEY `product_id` (`product_id`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=3 ;