View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

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 dori165961 | 1156 views | 7 replies

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.

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