function update_cart($cart, $productID, $quanlity) { $order = $cart['order']; $order_details = $cart['order_details']; foreach ($order_details as $key => $cart_item) { if ($cart_item['productID'] == $productID) { $cart_item['quanlity'] = $quanlity; $subtotal = get_subtotal($cart_item); $cart_item['subtotal'] = $subtotal; $order_details[$key] = $cart_item; $total = get_total($order_details); $order['total'] = $total; $cart['order'] = $order; $cart['order_details'] = $order_details; $_SESSION[session_id()] = $cart; if ($_SESSION[session_id()]) { return array('total' => $total, 'subtotal' => $subtotal); } else { return false; } } } }
?> "> </td> <td class="right"> $<?php echo $total; ?> </td> </tr> <?php } ?> <tr id="cart_footer"> <td colspan="3"><b>Subtotal</b></td> <td>$<?php echo get_subtotal(); ?> </td> </tr> <tr> <td colspan="4" class="right"> <input type="submit" value="Update Cart"> </td> </tr> </table> <p>Click "Update Cart" to update quantities in your cart. <br>Enter a quantity of 0 to remove an item. </p> </form> <?php }