PDA

View Full Version : How to unset eCart Variables


johnlanglois
03-31-2009, 01:41 PM
I hate to have to ask this again, but the answer in the old forum could not be found.

Upon return from PayPal, I want to clear the eCart so that the user can't hit the back key, change the order and submit it again.

Eric had a nice "how to clean it up" post in the old forum, but I can't find it.

I do not want to have a wholesale session destruction, because that would entail logging the client back in.

What functions should I call to empty the cart?

Thanks.

Ray Borduin
03-31-2009, 02:27 PM
What server language?... this question has been answered several times on the new forum for php. Have you searched this forum?

johnlanglois
03-31-2009, 08:02 PM
PHP.

I searched the forum, but only found one oblique reference to the idea.

Point me to a good list and I will be appreciative.

Ray Borduin
04-01-2009, 09:08 AM
http://www.webassist.com/forums/showthread.php?t=271&highlight=clearcart

would do the trick. I end up recommending:

$cartName->ClearCart();
unset($_SESSION['OrderID']);

neileisen207079
04-06-2009, 12:31 PM
Ray,
I got this to work, but when I put it in the top of the checkout success page - the receipt ends up being empty because it says the cart is empty. So its working, but it has to come after that page somehow. How is that normally handled?

thanks. I really need the help!

Ray Borduin
04-06-2009, 12:52 PM
Put it at the bottom of the page instead.

neileisen207079
04-06-2009, 01:44 PM
That seems to work, but I changed something else and I cant figure out what I did. The same OrderID is being rewritten each time, and now there is a NULL value in the OrderReferenceID and OrderTotal. Those fields were working before I started screwing around. I think I deleted the session variable for OrderID but I added it back in manually. Aghhh.

I am using Paypal if that matters and the orders are going through... it just isnt adding a new ORder to the Orders table... it is updating the same one, and as I said, setting those 2 fields to NULL.

neileisen207079
04-06-2009, 02:00 PM
I added this to the bottom of the checkout Success page and now it IS creating a new entry in the orders table each time:

<?php
$eCart1->ClearCart();
unset($_SESSION['OrderID']);
unset($_SESSION['eCart1_OrderID']);
?>

Now the only problem still seems to be something I did that causes the OrderTotal and OrderReferenceID to be NULL.

The previous orders had an OrderReferenceID that looks something like this:

ot3s52cegprk0793f5epd80of5

Any ideas Ray? Thanks in advance.

neileisen207079
04-06-2009, 02:32 PM
OK, My local copy of the Database didnt have those two fields, so the reference to them was removed in the add order to database behavior. I added those fields and mapped the Session ID and Grand Total and now it works. thanks for answering my other questions. Maybe this will help someone else, although I doubt anyone could duplicate such a stupid mistake.