Your code for determining if the cart is empty is a little more complex than you led on:
<?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
///////////////////
// 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 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.