Best way to extend the cart - 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: Best way to extend the cart (/showthread.php?tid=41720) |
Best way to extend the cart - El Forum - 05-15-2011 [eluser]cmgmyr[/eluser] Hey everyone, I'm trying to figure out a good way to extend the cart so that I can use different session names, but everything in the core library has "cart_contents" hard coded into it. I have a website with 2 different sections. Customers can have access to one, the other, or both. I need 2 different carts (ie: different session names), so that one cart doesn't bleed into the other (if the customer has access to both sections). The 2 different sections have 2 totally different products, database tables, and checkout process. So my question is: what is the best way of changing/extending the cart library so that I can dynamically change the session names? Thanks in advance. Best way to extend the cart - El Forum - 05-16-2011 [eluser]cmgmyr[/eluser] *bump* Best way to extend the cart - El Forum - 05-16-2011 [eluser]pickupman[/eluser] How about creating another class like called Customer_cart, and do a search and replace for "cart_contents". Then you could load cart and customer_cart. Best way to extend the cart - El Forum - 05-16-2011 [eluser]pickupman[/eluser] It's only in five spots. You could also extend the cart class with MY_Cart.php instead of 'cart_contents' being hard coded as the session variable, you could add a new property to the class called cart_key. Then you could make the get/set routines of the class require the session variable. Something like: Code: class MY_Cart extends CI_Cart{ |