[eluser]xwero[/eluser]
[quote author="Colin Williams" date="1234935452"]I think Cart might signal some shift in their practice though. I think they might be more focused on the concept of overloading libraries because Cart looks like a good interface/abstract class-like base for a more customized cart class. It's also the first official library that really blurs the line between model and library (just look at the API: insert(), update(), contents(), total_items(), etc). Maybe more light-weight, abstract-like classes are in the pipeline[/quote]
After i read Colin's remarks, above and about the session, i looked at the code and found out i have some troubles with the code. Colin writes about a abstract class like library but if you want to use another way to store the cart content between pages you have to overwrite the constructor because that is where the session library is called and the data is prepared for output, this could create a lot of problems because the CI instance is set to a class variable there. Wouldn't it be better to call the CI instance in the methods that use it instead of having a class variable of the instance? The constructor and the _save_cart method are the only ones that need it.
I also think the productname check is a bridge too far because you are can't internationalize a regex without adding a whole bunch of characters AFAIK.
On the subject of blurring the lines between model and library i think this is a bad mind set. Lazy programmers will add their database code to the MY_Cart.php file while the idea of models is to centralize all database actions.
I don't think the cart library is bad but it's a diamond in the rough.