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
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
after the </html> tag on the checkout succcess page, add the following code:
<?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();
?>
much appreciated
but why isn't this in the page created by the wizard?
clearing the cart on success is really a given. It may not be a desired result.
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?
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.
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.
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?
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.
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.
Your friends over here at WebAssist! These Dreamweaver extensions will assist you in building unlimited, custom websites.
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.