CodeIgniter Forums

Full Version: Create my own cart class named cart
You're currently viewing a stripped down version of our content. View the full version with proper formatting.

El Forum

[eluser]GeXus[/eluser]
I'd like to override the CI cart class, with my own Cart class, named cart. I need different functionality and for it to use a database instead of sessions.

I could call it MyCart or something, but I'd rather just have it 'Cart'. Any suggstions or reasons why I should just call it something else?

El Forum

[eluser]ipsod[/eluser]
Just go with the standard overwriting of CI classes. When you define a class using your prefix (usually MY_), it allows you to call it by saying $CI->cart->(etc.), effectively replacing CI's cart class.

Not sure why you'd care what the text file and class are titled when you can call it this way, unless it's some sort of severe OCD, in which case, seek help elsewhere.

El Forum

[eluser]GeXus[/eluser]
Thanks.. I think your more right about the OCD part, I've just named it My_Cart

El Forum

[eluser]ipsod[/eluser]
Haha, maybe so.

A certain amount of OCD is good. Just make sure you apply it right, like conforming to standards that make maintaining code easier.