Can't clear cart checkout & want to Empty cart on demand

Get help with nopcart Perl, PHP or ASP checkout related issues.

Moderators: Koibito, Stefko, Randy

Can't clear cart checkout & want to Empty cart on demand

Postby Ozmodiar » Thu Mar 16, 2006 5:55 am

i am using a perl program to handle checkout and can't get the cart to clear. i've pasted a thankyou.html file from another thread and that doesn't work - i can't get rid of the cart contents (everything else works fine).

also want to add a button on a "Review Cart" page where the user can empty the entire cart instead of removing items individually.

can anyone help!?

thanks
Ozmodiar
 
Posts: 2
Joined: Thu Mar 16, 2006 5:42 am

Postby Randy » Thu Mar 16, 2006 2:06 pm

There are 2 ways to clear the cart--

Add this button to managecart.html:
Code: Select all
<input onclick="ClearCart(); document.location=('managecart.html')" type="button" class="button" value=" Empty Cart " name="Empty">

Add this function to nopcart.js:
Code: Select all
//---------------------------------------------------------------------||
// FUNCTION:    ClearCart                                              ||
// PARAMETERS:  None                                                   ||
// RETURNS:     null                                                   ||
// PURPOSE:     To empty the shopping cart                             ||
//---------------------------------------------------------------------||

function ClearCart(){
      SetCookie ('NumberCookies', 0, null, '/');
   }




To empty the cart from thankyou.html, without loading the entire nopcart.js and language files, add this between the head tags:
Code: Select all
<SCRIPT type="text/javascript" language="javascript">
<!--
function ClearCart(){
      SetCookie ('NumberCookies', 0, null, '/');
   }

function SetCookie (name,value,expires,path,domain,secure) {
   document.cookie = name + "=" + escape (value) +
                     ((expires) ? "; expires=" + expires.toGMTString() : "") +
                     ((path) ? "; path=" + path : "") +
                     ((domain) ? "; domain=" + domain : "") +
                     ((secure) ? "; secure" : "");
}
//-->
  </SCRIPT>

and change the body tag to:
Code: Select all
<body onLoad="ClearCart();">


If you are asking for credit card information, your checkout must be on a secure server, which is a different domain than the unsecure store server. You will want to clear the cart on the store server that has managecart on it, so place your return page (thankyou.html) on that server, and add the proper path to checkout.pl. There is no need to empty the cart on the secure server, that will be overwritten with the next order, and the customer will never see it.

Remember that these cookies are only session cookies, and only persist as long as the browser is active. Once the browser is closed, there are no more cart content cookies.

Randy
JRS SERVICES
e-commerence solutions
www.jrsservices.net
Randy
Guru
 
Posts: 1511
Joined: Tue Apr 22, 2003 12:21 pm
Location: Thunder Bay, Ontario

Postby Ozmodiar » Thu Mar 16, 2006 9:01 pm

i still cannot get the cart to clear. i would like to concentrate on getting the empty on demand fuction to work because i really want that feature and if i can get that to work, surely i'll be able to clear it on checkout.

the code you sent for ClearCart() is executing and there is no error message, but the cart display remains unchanged. after seeing that i added a confirmation string (to track execution) and still no change on the cart.

i am running JavaScript Shop Module, V.4.4.0

in the managecart.html page, before the checkout button, i added:
<input onclick="ClearCart(); document.location=('managecart.html')" type="button" class="button" value=" Empty Cart " name="Empty">



in language-en file i added:
strEmpty = "Click 'Ok' to empty your shopping cart.";


in nopcart file i added:

//---------------------------------------------------------------------||
// FUNCTION: ClearCart ||
// PARAMETERS: None ||
// RETURNS: null ||
// PURPOSE: To empty the shopping cart ||
//---------------------------------------------------------------------||

function ClearCart(){
if ( confirm( strEmpty ) ) {
SetCookie ('NumberCookies', 0, null, '/');
}
}

i get the confirmation window, click ok, there's a little activity and the cart remains unchanged. i originally added your code unchanged and since nothing happened, i added the confirm to make sure the button was actually doing something.

am i doing something wrong? i have not debugged java before and so any help or hints are greatly appreciated.


thanks
Ozmodiar
 
Posts: 2
Joined: Thu Mar 16, 2006 5:42 am

Re: Can't clear cart checkout & want to Empty cart on demand

Postby cmgweb » Thu May 10, 2012 11:04 pm

My cart wont clear as well. I added exactly what it says and it doesnt work.


This is the thankyou.php to mail the form.
Code: Select all
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
 "http://www.w3.org/TR/html4/loose.dtd">
<HTML>
<HEAD>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<meta name="description" content="" />
<meta name="keywords" content="" />
<meta http-equiv="classification" content="" />
<meta name="subject" content="" />
<meta name="copyright" content="copyright(c)" />
<meta name="creator" content="calmktg.com" />
<meta name="author" content="artdept@calmktg.com" />
<meta name="audience" content="all" />
<meta name="robots" content="index,follow" />
<meta name="revisit-after" content="7 days" />
<meta name="Rating" content="General" />
<meta name="distribution" content="GLOBAL" />
<meta name="language" content="English" />
<link href="_css/screen.css" rel="stylesheet" type="text/css" />
<link rel="shortcut icon" href="../favicon.ico" />
  <TITLE>
    Thank Your for your order
  </TITLE>
<SCRIPT type="text/javascript" language="JavaScript">
//------------------------------------------------------------------||
//               NOP Design JavaScript Shopping Cart                ||
//                                                                  ||
// For more information on SmartSystems, or how NOPDesign can help you||
// Please visit us on the WWW at http://www.nopdesign.com           ||
//                                                                  ||
// FUNCTION:    DeleteCookie                                        ||
// PARAMETERS:  Cookie name, path, domain                           ||
// RETURNS:     null                                                ||
// PURPOSE:     Removes a cookie from users browser.                ||
//------------------------------------------------------------------||
function DeleteCookie (name,path,domain) {
   if ( GetCookie(name) ) {
      document.cookie = name + "=" +
                        ((path) ? "; path=" + path : "") +
                        ((domain) ? "; domain=" + domain : "") +
                        "; expires=Thu, 01-Jan-70 00:00:01 GMT";
   }
}

//---------------------------------------------------------------------||
</SCRIPT>
<SCRIPT type="text/javascript" language="javascript">
<!--
function ClearCart(){
      SetCookie ('NumberCookies', 0, null, '/');
   }

function SetCookie (name,value,expires,path,domain,secure) {
   document.cookie = name + "=" + escape (value) +
                     ((expires) ? "; expires=" + expires.toGMTString() : "") +
                     ((path) ? "; path=" + path : "") +
                     ((domain) ? "; domain=" + domain : "") +
                     ((secure) ? "; secure" : "");
}
//-->
  </SCRIPT>
</HEAD>
<div id="container">
   
   
   <div id="header">
     <div id="navcontainer">
        <ul>
            <li><a href="index.html">Home</a></li>
            <li><a href="fruit.html">Mens Shirts</a></li>
            <li><a href="vegetable.html">Womens Shirts</a></li><!--
            <li><a href="meat.html">Meat</a></li>-->
            <li><a href="../pages/managecart.html">Shopping cart </a></li>
            <li><a href="#">Contact us </a></li>
      </ul>
     </div>
   </div>
<body onLoad="ClearCart();">
<?php
$mailto = "artdept@calmktg.com" .$_POST['email'];
$subject = "Feedback form";
$message = "Values submitted from web site form:";
$header = "From: ".$_POST['email'];
foreach ($_POST as $key => $value)
{
   if (!is_array($value))
   {
      $message .= "\n".$key." : ".$value;
   }
   else
   {
      foreach ($_POST[$key] as $itemvalue)
      {
         $message .= "\n".$key." : ".$itemvalue;
      }
   }
}
mail($mailto, $subject, stripslashes($message), $header);
?>
Thank you for your order.  A conformation e-mail is waiting for you in your inbox.<BR><BR>
You may contact us at <A href="mailto:spam@nopdesign.com"> sales@yourstore.com</A>.
<BR><BR>
&nbsp;
<BR>
<H5>Thanks again for your order!</H5>
<BR><BR>
<H5>&copy;2008 California Marketing Group</H5>
<div id="footer">
      <div id="mc"><a href="http://www.calmktg.com" title="California Marketing Group" target="_blank"><span class="chunches">CMG</span></a></div>
   </div>
</div>
</body>
</html>


this is the added section in the nopcart.js
Code: Select all
//---------------------------------------------------------------------||
// FUNCTION:    ClearCart                                              ||
// PARAMETERS:  None                                                   ||
// RETURNS:     null                                                   ||
// PURPOSE:     To empty the shopping cart                             ||
//---------------------------------------------------------------------||

function ClearCart(){
      SetCookie ('NumberCookies', 0, null, '/');
   }
//


Please help me out.
cmgweb
WebMaster
 
Posts: 4
Joined: Wed May 09, 2012 3:27 pm

Re: Can't clear cart checkout & want to Empty cart on demand

Postby Koibito » Fri May 11, 2012 1:35 am

Code: Select all
function deleteAllCookies() {
    var cookies = document.cookie.split(";");

    for (var i = 0; i < cookies.length; i++) {
        var cookie = cookies[i];
        var eqPos = cookie.indexOf("=");
        var name = eqPos > -1 ? cookie.substr(0, eqPos) : cookie;
        document.cookie = name + "=;expires=Thu, 01 Jan 1970 00:00:00 GMT";
    }
}


Please note that this won't work if your cookies are configured to use a path or domain component.
John
Koibito
Site Admin / Guru
 
Posts: 918
Joined: Sun May 28, 2006 1:59 am
Location: New Jersey, USA


Return to Help: Perl/PHP/ASP Checkout

Who is online

Users browsing this forum: Google [Bot] and 0 guests

cron