close ad
Databridge V2 with MySQLi support IS Now Available!
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

rating

Cart not clearing

Thread began 4/14/2011 4:23 pm by mora398588 | Last modified 5/04/2011 1:07 pm by Jason Byrnes | 1850 views | 11 replies |

mora398588

Cart not clearing

After the creation of a guest sign in, I ran some tests and everything seemed to be working just fine.

However, I happen to notice that the cart was not cleared or emptied after a complete and successful transaction. The cart still showed the original items to be purchased.

Of course, this appeared to be a problem if a shopper wanted to go back and make another purchase. Are you able to determine what the cart may be doing?

I have provided my cart.php page for your convenience.

Attached Files
cart.zip
Sign in to reply to this post

Jason ByrnesWebAssist

add the following code to the checkout success page after the closing </html> tag:

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

mora398588

Thank you for the code. I followed your directions and updated my checkout_success page.

As you may know (through our recent discussions), that I currently use Auth.net (remote checkout) and PayPal.

With Auth.net, the checkout_success page is not returned to the shopper. Instead, a receipt is generated by Auth.net just after the shopper clicks the submit button when submitting their credit card info.

With Paypal, the same things occurs.

Should I insert this code on the confirm page?

Sign in to reply to this post

Jason ByrnesWebAssist

the confirm and pp_confirm pages should be directing to the checkout success page.


most likely, there is a php error occurring that is preventing the redirect from happening.

Add the following code at line one of both of those pages to turn error reporting on:

php:
<?php

error_reporting
(E_ALL);
ini_set('display_errors','on');
?>
Sign in to reply to this post

mora398588

The confirm and pp_confirm pages are directing to the respective success pages; however, the cart.php page is not destroying the session.

When I return to the cart page, the original order is still in the cart. Please review my previous replies for more information.

I have attached my success page for your review.

Attached Files
checkout_success.zip
Sign in to reply to this post

Jason ByrnesWebAssist

here is a small update to the session destroy code that should correct the issue.

it needs to go on each of the respective checkout success pages after the closing HTML tags.

to make sure that the change is being uploaded to the server, make a visual change to the page in addition to adding the code, this way, you can see at a glance whether the change is making it to the server.

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();
session_regenerate_id();
@
session_start();
?>
Sign in to reply to this post

mora398588

Concerning Auth.net...since I am using a remote checkout with Auth.net, will the updated code make a difference?

I inserted your updated code to the following files: checkout_success and pp_checkout_success.

Sign in to reply to this post

Jason ByrnesWebAssist

yes, once authorize.net returns you to to the success page, it will clear the cart contents.

Sign in to reply to this post

mora398588

You should know that when Auth.net processes a transaction remotely for our company, it returns a receipt page, not my success page.

Auth.net's receipt page is generated remotely by them and the only link that the receipt page provides is to my website's home page.

Any thoughts on this matter?

Sign in to reply to this post

Jason ByrnesWebAssist

you can customize the link that points back to your home page by modifying the form on the confirm page that sends the trasnsaction to authorize.net.

if the following elements arent there already, add them:


<input type="hidden" name="x_receipt_link_method" value="link">
<input type="hidden" name="x_receipt_link_text" value="return to our online store">
<input type="hidden" name="x_receipt_link_url" value="http://www.mydomain.com/index.php?cart=clear">


male sure to add:
/index.php?cart=clear

to the link url, this can be used to tell it to clear the cart by using the following code on the index.php page:

php:
<?php

if(isset($_GET['cart']) && $_GET['cart'] == "clear"){
// 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();
session_regenerate_id();
@
session_start();
}
?>
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...