Updating quantity of a specific item in cart? |
[eluser]umbongo[/eluser]
I am trying to make my code such that the number of items in the cart can be updated from within the cart. This is my code so far; Code: <?php echo form_open('basket/update/'); and the basket/update being pointed to; Code: function update($rowid) { I am a little unsure regarding passing variables in CI. I think I have to pass $rowid in the URL @ form_open, but what if I am changing the value for multiple items at once? I am also unsure how I would reference $items['rowid'] outside of the foreach loop (even if this isn't necessary). Some guidance would be appreciated.
[eluser]WanWizard[/eluser]
Don't pass values in the URI, unless it's a get operation. Use forms, and post the form. In case of multiple items, use arrays as form element names, so you can post as much as you want.
[eluser]umbongo[/eluser]
OK, well i was trying that above. code as is gives 'Undefined variable: i' and does not update quantities.
[eluser]cahva[/eluser]
In a nutshell View: Code: $i = 1; In controller to update you basically can do this: Code: if ($this->input->post('cart')) Thats overly simplified but you'll get the idea.
[eluser]umbongo[/eluser]
Thanks, works great! How should I limit the size and maxlength of the input form above? edit: i guess listed above is just the name part of the array in my OP.
[eluser]Unknown[/eluser]
Thanks for the code guys, Thi swas really advantage in my part. Keep it up and Godspeed! how to deal with depression |
Welcome Guest, Not a member yet? Register Sign In |