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

[eluser]tsnax4[/eluser]
[quote author="got 2 doodle" date="1235445899"]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[/quote]

I also found this bug, good catch, I just fixed it by setting the total value externally (couldnt figure out why it was adding wrong)
#32

[eluser]abmcr[/eluser]
[quote author="xwero" date="1234898929"]This morning my CI SVN updater notified me a new library was added to the framework : Cart.

I wonder what made the EL developers choose to add that library to the framework as it's seldom requested. Maturity? A shop module? No reason?

It seems the marriage of CI and EE is coming closer and this raises the question, where will CI stop and takes the EE core over?[/quote]

I think necessary also an official authentication library.... for a complete and CI only use of the Cart library
#33

[eluser]meigwilym[/eluser]
I've been using this on a small project. The cart contents total is a simple count() of the items in the cart array, and ignores the items' quantities.
Code:
$this->_cart_contents['total_items'] = count($this->_cart_contents);
I changed (improved?) the total_items() method with the following code to return the actual number of items:
Code:
function total_items()
    {
        // the old code
        // return $this->_cart_contents['total_items'];

        $total = 0;

        foreach($this->contents() as $item){
            $total = $total + $item['qty'];
        }

        return $total;
    }

Mei

EDIT: changed $this->_cart_contents to $this->contents()
#34

[eluser]Phil Sturgeon[/eluser]
[quote author="Mat-Moo" date="1235019003"]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?![/quote]

It may not be more important but it is more useful and has far less dependencies. I have made many auth libraries with different needs in different ways and not all of them apply to every site. Instead of overcomplicating life and making ONE AMAZING AUTH LIB I just keep all of them simple for their purpose.

This Cart library assumes nothing of your application structure, database structure, validation rules... it just doesn't care. It is good to have little tools like that that make application development more readable and clean, without forcing your structure or your flow in the slightest.

Thumbs up to libraries like Cart and thumbs down to official Auth library (even if it would make life "easier").




Theme © iAndrew 2016 - Forum software by © MyBB