Hi Everyone,
I have a cart operational, except when an item is added to the cart, its qty changed, it saved (to this point it all works fine) however when I click on continue shopping button it adds another item qty to the new item. Then I click on continue shopping for a second time and it takes me to where i want to go. What could be the issue? Here is the code for my cart, what else would help solve this prob?
I have a cart operational, except when an item is added to the cart, its qty changed, it saved (to this point it all works fine) however when I click on continue shopping button it adds another item qty to the new item. Then I click on continue shopping for a second time and it takes me to where i want to go. What could be the issue? Here is the code for my cart, what else would help solve this prob?
Code:
<?php
// The shopping cart needs sessions, so start one
session_start();
include ('book_sc_fns.php');
$new;
if (isset($_GET['new'])) {
$new = ($_GET['new']);
}
if($new)
{
//new item selected
if(!isset($HTTP_SESSION_VARS['cart']))
{
$HTTP_SESSION_VARS['cart'] = array();
$HTTP_SESSION_VARS['items'] = 0;
$HTTP_SESSION_VARS['total_price'] ='0.00';
}
if(isset($HTTP_SESSION_VARS['cart'][$new]))
$HTTP_SESSION_VARS['cart'][$new]++;
else
$HTTP_SESSION_VARS['cart'][$new] = 1;
$HTTP_SESSION_VARS['total_price'] =
calculate_price($HTTP_SESSION_VARS['cart']);
$HTTP_SESSION_VARS['items'] = calculate_items($HTTP_SESSION_VARS['cart']);
}
if(isset($HTTP_POST_VARS['save']))
{
foreach ($HTTP_SESSION_VARS['cart'] as $design_id => $qty)
{
if($HTTP_POST_VARS[$design_id]=='0')
unset($HTTP_SESSION_VARS['cart'][$design_id]);
else
$HTTP_SESSION_VARS['cart'][$design_id] = $HTTP_POST_VARS[$design_id];
}
$HTTP_SESSION_VARS['total_price'] =
calculate_price($HTTP_SESSION_VARS['cart']);
$HTTP_SESSION_VARS['items'] = calculate_items($HTTP_SESSION_VARS['cart']);
}
do_html_header('Your shopping cart');
do_cart();
do_search();
// get categories out of database
$cat_array = get_categories();
// display as links to cat pages
display_categories($cat_array);
?></div></div>
<div id="content" style="position:absolute; width:562px; height:450px; z-index:4; left: 173px; top: 10px; overflow: scroll;">
<div align="center"><img src="images/shoppingcart.gif" width="129" height="40"></div><br>
A 99 cent service fee is included for purchases under $10. Once you have selected all your embroidery designs and collections, make your payment with paypal by clicking on the "go to checkout" button.
<div align="center"><img src="images/tenpercent.gif" width="206" height="66"></div>
<?php
if($HTTP_SESSION_VARS['cart']&&array_count_values($HTTP_SESSION_VARS['cart'])){
display_cart($HTTP_SESSION_VARS['cart']);
?>
<hr><br>
<div align="center"><a href="javascript:history.go(-1)"><img src="images/continueshopping.gif" alt="Continue shopping" width="110" height="43" border="0"></a></div>
<hr>
<br><br><form action="[URL unfurl="true"]https://www.paypal.com/cgi-bin/webscr"[/URL] method="post">
<input type="hidden" name="cmd" value="_cart">
<input type="hidden" name="business" value="info@cds.com">
<input type="hidden" name="upload" value="1">
<input type="hidden" name="currency_code" value="AUD">
<?php paypal_output($HTTP_SESSION_VARS['cart']); ?>
<div align="center"><strong>Ready to Buy!</strong><br><br>Make payments with PayPal - it's fast, free and secure!<br>
<input type="image" src="[URL unfurl="true"]http://www.carolinesdigistitching.com/images/gotocheckout.gif"[/URL] border="0" name="submit" alt="Make payments with PayPal - it's fast, free and secure!">
</div>
</form>
<?php
}
else{
echo "Your shopping cart is empty!";
}
?>
</div><?php
do_html_footer();
?>