Welcome Guest, Not a member yet? Register   Sign In
Is the Cart.php library a sign that more libraries are coming?
#21

[eluser]Tom Schlick[/eluser]
[quote author="Colin Williams" date="1234937232"]
Quote:even if you dont use them they give you ideas on how to better structure your code

That's what I was hinting at in a much more rambunctious manner Smile If this isn't something they consider, it should be. The idea of a bunch of small, helpful libraries makes sense to me. So yeah, I welcome it too.[/quote]

yeah i didnt even go to the second page before i replied haha after i did and saw ur post basically saying the same thing Smile
#22

[eluser]Tom Schlick[/eluser]
just looking at the changelog and it looks like rickellis fixed the session_destroy with the cart to just remove the cart. not the user's session Smile
#23

[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.
#24

[eluser]Mat-Moo[/eluser]
A cart would be brill for a project I'm working on... although I find it odd that Auth is not important and Cart is?!
#25

[eluser]Colin Williams[/eluser]
They can fire out something like Cart in a few days. Not so much with an Auth system. But I still argue that with a Database class and a secure Session class, you essentially have an Auth system.
#26

[eluser]Crimp[/eluser]
New Cart.php? I'll check it out! ;-)
#27

[eluser]tsnax4[/eluser]
So this is my first post but I have been lurking for a while. It just so happens that I was in the process of building a cart when I saw this so I put it to the test, and it works very well. Now a question that relates to this. Anyone have any idea how this will work with the paypal api? Im new to the API and am trying to use the express checkout functionality, but their code needs session variable access, would I edit their functions to access the CI session variables?
#28

[eluser]simshaun[/eluser]
I like where the lib is heading.
I don't see it as something important (half the other libs/helpers aren't important to me either..), but its nice to have it there when you need it.

The whole point of the framework is to save time, and thats what this does.
Having an Auth system would be nice, but I think there is a fine line in how it should work, because it kinda depends on applications' needs.

Now, something I'd like to see is something like Zend's ACL library in CI. (I've ported a version, but I'm sure the CI crew could make it better/quicker than I.) I like it because its built so you can use it in a variety of ways and is not coupled to a database.
#29

[eluser]got 2 doodle[/eluser]
Happy to hear about the cart lib

Code:
if($this->more_libs) {
     ++$usefulness;
    } else {
    $same_same;
    }

doodle Smile
#30

[eluser]got 2 doodle[/eluser]
I think I found a bug in this new library, at least on my machine (could be a windows issue but I don't think so).

The cart total is incorrect, the cart save function always adds extra stuff because it continues looping even though the qty and price keys are not there.

The fix (hack?) is to do this to line 381 of the cart.php file.
Code:
if(count($val) > 1)    $total += ($val['price'] * $val['qty']);

previously this line read
Code:
$total += ($val['price'] * $val['qty']);

There could be a better solution but at least it works now.

doodle




Theme © iAndrew 2016 - Forum software by © MyBB