can't update quantity of the cart
Closed this issue · 7 comments
Hello,
i cant update the quantity of my cart.
here is my code:
`
if($_GET['do'] == "change")
{
$quantity = $_POST['quantity'];
$id = $_GET['id'];
$cart->update($id, $quantity);
header('location: cart.php');
exit;
}
`
Can you find out the ID is matching any item in your cart?
You may dump out items in your cart to compare:
print_r($cart->getItems());
yeah, the id is the id which i read from the array
Array ( [6] => Array ( [0] => Array ( [id] => 6 [quantity] => 1 [hash] => 39f5bab66576353c2754745df1ce6de2 [attributes] => Array ( [price] => 8.00 [name] => Antipasto[size] => Standard ) ) )
so, the $id = 6
and the quantity is from the post (text input)
remove function works fine with ID..
It seems like your item is having extra attributes. You will need to update the item with its attributes.
This is because some stores may have items with same ID, but different atributes.
$cart->update(6, $quantity, [
'price' => 8.00,
'name' =>'Antipasto' ,
'size' => 'Standard'
]);
ahh okay now it works! Thank you!
hi
in example file You need to put a jquery before bootstrap js
in line 255 and 256