Shopping Cart with Checkout Using CodeIgniter

Submitted by: 
Language: 
Visitors have accessed this post 56030 times.

This shopping cart is using CodeIgniter framework that allows you to add/update/delete a product from the cart. I am using the database in my previous post as a fixed on the existing shopping cart I found in the internet.
This code is totally different from the code at “How to Build Shopping Cart w/ Checkout in PHP”. It has a cleaner code, secured and most importantly easy to understand.
Shopping cart with checkout using CodeIgniter is part of the tutorial that I am currently working. I will explain this one by one on how I created this code in the next few days.
It's so easy to create a cart using CodeIgniter. Here's an example code:

  1. public function add()
  2. {
  3. $this->load->model('Cart_model');
  4.  
  5. $insert_room = array(
  6. 'id' => $this->input->post('id'),
  7. 'name' => $this->input->post('name'),
  8. 'price' => $this->input->post('price'),
  9. 'qty' => 1
  10. );
  11.  
  12. $this->cart->insert($insert_room);
  13.  
  14. redirect('cart');
  15. }

Note: Due to the size or complexity of this submission, the author has submitted it as a .zip file to shorten your download time. After downloading it, you will need a program like Winzip to decompress it.

Virus note: All files are scanned once-a-day by SourceCodester.com for viruses, but new viruses come out every day, so no prevention program can catch 100% of them.

FOR YOUR OWN SAFETY, PLEASE:

1. Re-scan downloaded files using your personal virus checker before using it.
2. NEVER, EVER run compiled files (.exe's, .ocx's, .dll's etc.)--only run source code.

Comments

Is it possible to get database of this turorial or not even fields name? i am stuck without db..
thanks

thanls you very much

Hi, I wonder if you are able to mail me that db-file("shopping")that seems to be used in the database config file. Please send it to [email protected]

Regards Bengt (from Sweden)

The database can be found on the other shopping cart. But I have added it again on the download link above for your convenience.

thank u very much its help more for bignner:)

how to use this in xampp
and the how can i import the database?

How to connect code billing.php, cart.php, & products.php!?

THis code is not working

Open application/config/config.php
Modify $config['base_url'], $config['index_page']

Products page opens, but Add to cart gives an 404 error.

Can you insert <?php echo (index_page()) ? index_page().'/':''; ?> after base_url()

Example <?php echo base_url(); ?><?php echo (index_page()) ? index_page().'/':''; ?>

$config['base_url'] = 'http://localhost/codeigniter_cart/';
$config['index_page'] = 'index.php';

what exactly do i change?

Thank you so much for all these code snippets it's really helpful and easy to understand :)

You don't have permission to access /Shopping/cart/add on this server.
when i try to add to cart

Add new comment

Filtered HTML

  • Web page addresses and e-mail addresses turn into links automatically.
  • You may insert videos with [video:URL]
  • Allowed HTML tags: <a> <em> <strong> <cite> <blockquote> <code> <ul> <ol> <li> <dl> <dt> <dd> <table> <tr> <td> <th> <img> <h1> <h2> <h3> <iframe> [video]
  • You can enable syntax highlighting of source code with the following tags: <code>, <blockcode>, <asp>, <c>, <cpp>, <csharp>, <css>, <html4strict>, <java>, <javascript>, <mysql>, <php>, <python>, <sql>, <vb>, <vbnet>. The supported tag styles are: <foo>, [foo].
  • Lines and paragraphs break automatically.

Plain text

  • No HTML tags allowed.
  • Lines and paragraphs break automatically.
CAPTCHA
This question is for testing whether or not you are a human visitor and to prevent automated spam submissions.