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

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

rating

isEmpty() incorrectly returns true on checkout success page

Thread began 12/04/2009 12:29 pm by dori165961 | Last modified 12/10/2009 4:37 pm by Jason Byrnes | 1267 views | 7 replies |

dori165961

isEmpty() incorrectly returns true on checkout success page

I have a client whose eCart store has worked great for over a year. About a week or two ago their customers started getting an empty cart error message on the checkout success page after placing an order.

The error message the customer sees is "Session Timed Out... Your order information could not be found." It's a custom error message I wrote that is only displayed if the cart is empty (so the customer doesn't see a blank order form if their session expired). In other words:

if (!$eCart1->IsEmpty())
// display shopping cart info
} else {
// display empty cart message
}

When I comment these lines, the shopping cart items and total are displayed properly.

We're using PayPal local checkout and this problem happens with both credit card and PayPal payments. My client reports that the problem is intermittent but has been happening with increased frequency lately.

Does anyone have any ideas why eCart is incorrectly returning true in this situation? Any thoughts are GREATLY appreciated.

Sign in to reply to this post

Jason ByrnesWebAssist

hard to say without seeing the code in context. Can you send a copy of the page that is not working correctly so I can examine the code.

Sign in to reply to this post

dori165961

Thanks for taking a look. Here's are three files:

confirm.php is the page where the customer reviews their order before clicking "Place Order"
checkout_success.php is the success page when paying by credit card
pp_checkout_success.php is the success page when paying with PayPal

The server runs Apache with PHP Version 5.2.11

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

Jason ByrnesWebAssist

Your code for determining if the cart is empty is a little more complex than you led on:

php:
<?php

///////////////////
// If the cart is empty, it means the SESSION has expired.
// Don't redirect the customer -  display a message instead
///////////////////
?>
<?php 
if((!$_SESSION['OrderType']) && ($eCart1->IsEmpty()) && ($eCart2_giftcards->IsEmpty())) {
  
$display_empty_message "cart1_empty";
  }
?>
<?php 
if($_SESSION['OrderType'] != "giftcards") { ?>
<?php
if ($eCart1->IsEmpty())     {
  
$display_empty_message "cart1_empty";
}
?>
<?php 
} else { ?>
<?php
if ($eCart2_giftcards->IsEmpty())     {
  
$display_empty_message "cart2_giftcards_empty";
}
?>
<?php 
// END of if($_SESSION['OrderType'] != "giftcards") ?>




to trouble shoot, I would change that code slightly:

php:
<?php

///////////////////
// If the cart is empty, it means the SESSION has expired.
// Don't redirect the customer -  display a message instead
///////////////////
?>
<?php 
if((!$_SESSION['OrderType']) && ($eCart1->IsEmpty()) && ($eCart2_giftcards->IsEmpty())) {
  
$display_empty_message "cart1_empty - eCart2_giftcards_empty - not Session OrderType";
  }
?>
<?php 
if($_SESSION['OrderType'] != "giftcards") { ?>
<?php
if ($eCart1->IsEmpty())     {
  
$display_empty_message "cart1_empty";
}
?>
<?php 
} else { ?>
<?php
if ($eCart2_giftcards->IsEmpty())     {
  
$display_empty_message "cart2_giftcards_empty";
}
?>
<?php 
// END of if($_SESSION['OrderType'] != "giftcards") ?>






then I would change part to display your custom message slightly to help track down the problem:

php:
<?php if($display_empty_message) { ?>

Empty message: <?php echo($display_empty_message); ?>
Order Type: <?php echo($_SESSION['OrderType']); ?>
...




this will help to determine where to look for the problem by telling us which if statement is failing.


Then you need to twiddle the logic down, once you know which if statement is failing, you c an look into why.


Since you report this is happening intermittently, it may be a problem on the server. cart contents are stored in session variables, the server could have a problem in the session garbage collection where it is emptying the session temp files to soon, you would need to check with the host on that one.

Sign in to reply to this post

dori165961

If you look in the body of the page where the cart contents are displayed, the code there is standard WA eCart code and not dependent on those if/then statements you pointed out. Disregarding the custom "Session Timed Out" message, the cart contents are simply blank on some occasions. The logic there uses isEmpty(). When I comment out the isEmpty statement, the cart contents will appear as they should.

I think you might be onto something with the session garbage collection, but I doubt the host (BlueHost) would admit to having a problem. My client just informed me that they remember BlueHost doing a server upgrade or maintenance of some sort November 25th, and that's when the problems started happening.

Sign in to reply to this post

Jason ByrnesWebAssist

maybe try adding this code just before the cart if statement:

php:
<?php

$eCart1
->GetContent();
?>
<?php
$eCart2_giftcards
->GetContent();
?>




to force it to look for the cart information again.

Sign in to reply to this post

dori165961

The solution you suggested about GetContent seems to be working, unless there was something server-side going on that was fixed. The BlueHost server my client is on has been down 4 or 5 times this week. Either way, we're happy things are running smoothly again. Thanks so much for your help.

Sign in to reply to this post

Jason ByrnesWebAssist

Excellent, glad to hear it is working.

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