close ad
Install the LAtest Updates to Work with CC 2017 and CC 2018
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

rating

ecart 5 - second day use - wizard checkout doesnt clear cart

Thread began 2/10/2010 11:16 am by web_assist_mail157665 | Last modified 2/17/2010 2:42 pm by Jason Byrnes | 1846 views | 17 replies |

web_assist_mail157665

ecart 5 - second day use - wizard checkout doesnt clear cart

if you get to the success page after placing an order

and then back to a cart page
the last order is still there?

please advise

Sign in to reply to this post

Jason ByrnesWebAssist

after the </html> tag on the checkout succcess page, add the following code:

php:
<?php

// Initialize the session.
// If you are using session_name("something"), don't forget it now!
session_start();

// Unset all of the session variables.
$_SESSION = array();

// If it's desired to kill the session, also delete the session cookie.
// Note: This will destroy the session, and not just the session data!
if (ini_get("session.use_cookies")) {
    
$params session_get_cookie_params();
    
setcookie(session_name(), ''time() - 42000,
        
$params["path"], $params["domain"],
        
$params["secure"], $params["httponly"]
    );
}

// Finally, destroy the session.
session_destroy();
?>
Sign in to reply to this post

web_assist_mail157665

much appreciated

but why isn't this in the page created by the wizard?

Sign in to reply to this post

Jason ByrnesWebAssist

clearing the cart on success is really a given. It may not be a desired result.

Sign in to reply to this post

codamedia

Not a very good desired affect at all.

A success page should be clearing all "CART" contents along with the "CART" unique ID. However, this solutions clears every session - including some that are desired such as a client logon.

Is there no easy way to clear just session elements that are related to the cart?

Sign in to reply to this post

web_assist_mail157665

Can we have some code to JUST clear the cart please.

This is to be expected and it doesn't happen.

The supplied code logs my users out - that is not at all what is required. eCart has suitable cart clearing code - can we have a copy of this for the order confirm page pls.

Sign in to reply to this post

codamedia

I have found another post that goes over this. It works but it is not a very elegant solution.

showthread.php?t=9799

eCart seems to create and use so many session variables this is the obvious "quick" solution - but ugly at best!

Simply destroying the "Unique Cart ID" would solve the problem to some extent, and allow a new order to trigger - but it still leaves all the "values, shipping, billing info, shipping info, etc..." in sessions. That could really cause headaches under certain situations.

Sign in to reply to this post

web_assist_mail157665

What about....If you create a blank page, then add a 'clear cart' button

that seems to add the appropriate code to the page
as far as i can see - if you run the clear cart bit without testing for the button or redirecting that should do the job?


require_once("WA_eCart/eCart1_PHP.php");
?>
<?php
$eCart1->GetContent();
?>
<?php
// WA eCart Clear Cart
if (isset($_POST["eCart1_Clear_1"]) || isset($_POST["eCart1_Clear_1_x"])) {
$eCart1->ClearCart();
$Redirect_redirStr="xxxxxxx.php";
if ($Redirect_redirStr != "") {
$eCart1->redirStr = $Redirect_redirStr;
}
$eCart1->cartAction = "ClearCart";
}
?>

ie

<?php
require_once("WA_eCart/eCart1_PHP.php");
$eCart1->GetContent();//do we need this?
$eCart1->cartAction = "ClearCart";
?>

or have I missed something?

Sign in to reply to this post

codamedia

I'm not sure if that actually clears the carts unique Session ID? If it doesn't clear the session id - then if the person decides to do another purchase, it will overwrite their original purchase in the database.

I'm not 100% sure how that is operating, I'm just throwing that out there as a scenerio at this time. Hopefully I can do some tests on this and find a good solution.

Sign in to reply to this post

codamedia

My Solution

I have found a solution to this problem that works for me.

eCart gives all of it's Session Variables names that start with "eCart" and/or start with "orders". Based on that information - I was able to come up with an automated solution, without hard coding every scererio.

This is the code that I place after my HTML at the end of the order success page.

// Find all instances of eCart Sessions and unset them
foreach($_SESSION as$key => $value){
if(('order' === substr($key, 0, 5)) || ('eCart' === substr($key, 0, 5))){
unset($_SESSION[$key]);
}
}



There are limits to this code:
1: If you have any custom session names that start with order or eCart - they also will get killed.
2: This does not take care of any cookies, if you use them.
3: If you are using the "session ID" as the unique cart identifier, this will not help because it is not reset. In my case, I have setup a unique way to manage cart instances.

Sign in to reply to this post
loading

Build websites with a little help from your friends

Your friends over here at WebAssist! These Dreamweaver extensions will assist you in building unlimited, custom websites.

Build websites from already-built web applications

These out-of-the-box solutions provide you proven, tested applications that can be up and running now.  Build a store, a gallery, or a web-based email solution.

Want your website pre-built and hosted?

Close Windowclose

Rate your experience or provide feedback on this page

Account or customer service questions?
Please user our contact form.

Need technical support?
Please visit support to ask a question

Content

rating

Layout

rating

Ease of use

rating

security code refresh image

We do not respond to comments submitted from this page directly, but we do read and analyze any feedback and will use it to help make your experience better in the future.

Close Windowclose

We were unable to retrieve the attached file

Close Windowclose

Attach and remove files

add attachmentAdd attachment
Close Windowclose

Enter the URL you would like to link to in your post

Close Windowclose

This is how you use right click RTF editing

Enable right click RTF editing option allows you to add html markup into your tutorial such as images, bulleted lists, files and more...

-- click to close --

Uploading file...