Hi All,
So I an creating an online store just to play around with code and learn from it. I am building a store and on the confirmation page, I am trying to update the QTY of items in a cart by using the '-' or '+' buttons. However I am having no luck at all.
Here is my code:
<?php
foreach ($_SESSION["cart_item"] as $item){
$item_price = $item["quantity"]*$item["price"];
?>
<tr>
<td><img src="<?php echo $item["image"]; ?>" class="cart-item-image" /><?php echo $item["name"]; ?></td>
<td><?php echo $item["code"]; ?></td>
<td style="text-align:center;">
<table class ="cart-info">
<tbody>
<tr>
<form method='post'>
<td>
<button class="btn-increment-decrement" id="add" onClick="decrement_quantity(<?php echo $_SESSION['quantity']-- ?>, <?php echo $_SESSION['price']; ?>)">-</button>
</td>
<td>
<input class="input-quantity" id="input-quantity-<?php echo $item["cart_id"]; ?>" value="<?php echo $item["quantity"]; ?>"></td>
<td>
<button class="btn-increment-decrement"
onClick="increment_quantity(<?php echo $_SESSION['quantity']++; ?>, '<?php echo $_SESSION['price']; ?>')">+</button>
</td>
</form>
</tr>
</tbody>
</table>
</td>
<td style="text-align:right;"><?php echo "£ ".$item["price"]; ?></td>
<td style="text-align:right;"><?php echo "£ ". number_format($item_price,2); ?></td>
<td style="text-align:center;"><a href="?action=remove&code=<?php echo $item["code"]; ?>" class="btnRemoveAction"><img src="images/icons/delete.png" alt="Remove Item" /></a></td>
</tr>
<?php
$total_quantity += $item["quantity"];
$total_price += ($item["price"]*$item["quantity"]);
}
?>
Here is the UI Click Here
Thanks