close ad
WARNING: Do Not Install the DREAMWEAVER CC 2017 or 2018 Update »
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

rating

Insert order vs Update order

Thread began 4/28/2010 1:17 am by lejohnson01403530 | Last modified 4/29/2010 3:58 pm by Jason Byrnes | 784 views | 3 replies |

lejohnson01403530

Insert order vs Update order

I am seeing that when I click the checkout button from the cart page (eCart 5) and then click the submit order button on the confirm page, the order gets added to both the orders and orderdetails tables. This is as expected. However, if I go right back to the cart and click checkout and submit the order again, rather than adding a new entry to the db, I see that the previous entries are updated. I was not expecting an update.

Can you explain how this is expected to work? And shouldn't the cart be cleared after an order is submitted? If so, how?

Sign in to reply to this post

Jason ByrnesWebAssist

To clear the cart after an order is placed, add the following code after the closing </html> tag on the checkout success page:
<?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

lejohnson01403530

I don't really want to unset all session vars. I have several other session vars for the site the I want to keep in place. I just want to clear the cart itself.

Sign in to reply to this post

Jason ByrnesWebAssist

the cart contents are stored in a session named "<eCart Object Name>_Items", where <eCart Object Name> is the name of your eCart object.

The Order ID is stored in a session that is created by the Store order summary server behavior on the confirm page.

Double click the store order summary server behavior on the confirm page and note the name that the Order ID is being saved as.

now add the following code on the checkout success page after the closing </html> tag

php:
<?php 

if ("" == ""){
  
// WA_ClearSession
    
$clearAll FALSE;
    
$clearThese explode(",","OrderID,Cart_Items");
    if(
$clearAll){
        foreach (
$_SESSION as $key => $value){
            unset(
$_SESSION[$key]);
        }
    }
    else{
        foreach(
$clearThese as $value){
            unset(
$_SESSION[$value]);
        }
    }
}
?>





change:
$clearThese = explode(",","OrderID,Cart_Items");


to the names of the OrderID session variable and the Cart items session variable.

Sign in to reply to this post

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...