I am having an issue with the Update basket and Checkout buttons, when you click update basket it loads the /checkout/ page but then redirects back to the /cart/ after a couple of seconds when it should just load a new page saying 'Shopping basket successfully updated' - also, when you click the proceed to checkout button it does the same, loads the /checkout/ page (which is correct) but then redirects back to /cart/.
Here is the php code I have setup:
Code: Select all
// View Shopping Basket
if (!isset($_GET['action']) || $_GET['action'] == 'products') {
// Check if the shopping basket is empty
if ($cart->get_num_products(session_id()) <= 0) {
output('Your shopping basket contains no products!');
} else {
if (!isset($_POST['submit'])) {
$tpl->set('body', $body->fetch('index.tpl.php'));
} else {
$cart->update_contents(session_id());
output('Shopping basket successfully updated!');
redirect('/cart/', 2);
}
}
}
// Add Product to Cart
if (isset($_GET['action']) && $_GET['action'] == 'add_product') {
$product_id = isset($_GET['product_id']) && is_numeric($_GET['product_id']) ? (int) $_GET['product_id'] : 0;
$cart->add_product(session_id(), $product_id, 1);
output('Product successfully added! Please wait while we redirect you to your shopping basket.');
redirect('/cart/', 2);
}
if (isset($_SESSION['coupon_code'])){
unset($_SESSION['coupon_code']);
}
if (isset($_POST['go']) && $_POST['go'] != ''){
$_SESSION['coupon_code'] = $_POST['coupon_code'];
header("location:/checkout/");
exit;
}[text]<form method="post" action="/cart/">
<input type="hidden" name="submit" value="Update" />
<input type="hidden" name="go" value="true" />
<label><strong>If you have a promotion voucher code please enter it here: </strong></label>
<input type="image" src="<?php echo '/' . $config['image_path']; ?>button_cart_update.gif" border="0" alt="Update Shopping Basket" /> <a href="/shop-11/"><img src="<?php echo '/' . $config['image_path']; ?>button_continue.gif" border="0" alt="Continue Shopping" /></a> <input type="image" name="checkout" src="<?php echo '/' . $config['image_path']; ?>button_checkout.gif" border="0" alt="Proceed to Checkout" /></div>
</form>[/text]
If anybody can spot whats wrong I would really appreciate it. - It is probably something so simple but I am finding ti quite frustrating.
Thanks,
Paul