Welcome Guest, Not a member yet? Register   Sign In
Removing the last item of a cart
#1

[eluser]Блум[/eluser]
Hello,
I just found out that if an item is the last one in the cart, I can not remove it by:
Code:
$data = array(
            'rowid' => $row_id,
            'qty' => 0
        );
$this->cart->update($data);
It just stays there. If there is more than one item in the cart, everything is fine, the item gets removed.
Is it normal or is it a bug? Should I check if there is only one item in the cart and remove it with $this->cart->destroy()?
I'm using CI 2.0.2.
Thanks
#2

[eluser]Sudz[/eluser]
Sorry by mistake it was posted.
follow this
http://ellislab.com/codeigniter/user-gui.../cart.html
#3

[eluser]Блум[/eluser]
answer to the upper mistaken post
..but why? This is definitely not going to remove it.
#4

[eluser]Блум[/eluser]
As it is written in http://ellislab.com/codeigniter/user-gui.../cart.html :
Code:
$data = array(
            'rowid' => $row_id,
            'qty' => 0
);
$this->cart->update($data);
should remove it. But it doesn't. :/ Talking about the last single item in the cart.
#5

[eluser]Sudz[/eluser]
$row_id is matching or not?
#6

[eluser]Блум[/eluser]
Yes, it matches. Since I can increase the quantity.. and decrease it to 1.
#7

[eluser]Sudz[/eluser]
Study this tutorial it will help you
http://blog.insicdesigns.com/2010/01/bui...art-class/
#8

[eluser]Блум[/eluser]
[quote author="Sudhakar Prajapati" date="1304437771"]Study this tutorial it will help you
http://blog.insicdesigns.com/2010/01/bui...art-class/[/quote]

I'm afraid it can't help me, the example in there doesn't even have a cart item removal.. and at the end is not well done.
#9

[eluser]Sudz[/eluser]
Refer the code in file attachment
#10

[eluser]Блум[/eluser]
It seems like it is written for some old CI version, isn't it? And it uses some "products" db table which is not provided in this example..
Anyway I run it just to be sure, and it has absolute the same behavior, and it should, since it has nothing really different than we discussed in the previous posts.
Can anyone confirm my statement, that (on CI 2.0.2) the last single element in the cart can not be removed with 'qty' => 0?




Theme © iAndrew 2016 - Forum software by © MyBB