Basic Cart Example - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23) +--- Thread: Basic Cart Example (/showthread.php?tid=22528) Pages:
1
2
|
Basic Cart Example - El Forum - 09-12-2009 [eluser]SitesByJoe[/eluser] I just started playing with the cart class today. I looked around and didn't see a decent example of the basic functions working together so I whipped up a rough example for newbies to play with who are trying the cart for the first time and are confused. This is a very basic example and I only used a controller since I'm just roughing it together as I post this. No proper MVC is being used - everything is in the controller so you can absorb what's happening very quickly. The code may very well be missing things that advanced programmers are free to mention. Enjoy! The one table so far, "products" Code: CREATE TABLE `products` ( Controller Code up next... Basic Cart Example - El Forum - 09-12-2009 [eluser]SitesByJoe[/eluser] Controller Code: Code: class Shop extends Controller { Basic Cart Example - El Forum - 09-13-2009 [eluser]John_Betong[/eluser] Hi Joe, http://johns-jokes.com/ci_jokes/c_shop/ Many thanks for a great example. I played around with it and came up with the above demo. I am now off to incorporate it into my site and try and sell some jokes Basic Cart Example - El Forum - 09-13-2009 [eluser]SitesByJoe[/eluser] I'm glad you were able to make use of it. That was exactly the point. Jump in and play with the cart so you understand how it works. Good luck with the shop. Basic Cart Example - El Forum - 09-13-2009 [eluser]daparky[/eluser] Looking good, thanks Joe. Is there a way of displaying the products all on one page, using checkboxes next to the product(s) you want and then when you submit it adds them to the cart? An example of something i want goes like this: A products one page where users enter personal details and select the products they want. When the user submits, it inserts that data into a database. Obviously at a later date if the user wants to change what they want they can do. There will be no quanities, everything will be 1. Thanks, David. Basic Cart Example - El Forum - 09-30-2009 [eluser]fourmi[/eluser] Joe, Thanks million Will showcase mine when I'm done Whoop Whoop! Ant Basic Cart Example - El Forum - 09-30-2009 [eluser]fourmi[/eluser] Hmm, any ideas on how to have a product that's say a 10 buck discount coupon? have been digging deep and setting -ve qty/price doesn't seem to get through to the library, messed about there, learned to love ctrl-z! cheers ant Basic Cart Example - El Forum - 10-01-2009 [eluser]fourmi[/eluser] ok got around -ve prices, and qtys by commenting out the is valid number style checking in the class seach for "Prep the quantity. It can only be a number. Duh..." and "Prep the price. Remove anything that isn't a number or decimal point." while i was ther ei also got rid of the name format check (threw wobblies with £ signs "Validate the product name. It can only be alpha-numeric, dashes, underscores, colons or periods." all in system/libraries/Cart.php cheers Basic Cart Example - El Forum - 10-01-2009 [eluser]garaki[/eluser] How do I implement the checkout functionality in the above function? Basic Cart Example - El Forum - 10-07-2009 [eluser]fourmi[/eluser] add a checkout form to the code in the show_cart function duplicate show_cart renaming it checkout then edit the checkout function to do whatever you want to do with the data (ie rip out markup and create an sql till insert or soemthing) play .. it'll become clear |