So close
Hello,
My rule works perfectly when outside the loop looking for intersection candidates. But also using the loop can bypass a valid hit and carry on to a non intersection as the final record in the loop which by passes the rule being true.
Solution: Move to a loop that stops whenever finding a valid intersection.
But this does not work for some reason:
<?php // envoke if more than 1 Item in cart
if (sizeof($eCart1->Items)>1) { ?>
<?php
// setting up base variables
$startDate = $eCart1->DisplayInfo("startDate");
$endDate = $eCart1->DisplayInfo("endDate");
?>
<?php // loop available items for comparison
$rule = 0;
while (!$eCart1->EOF() && $rule == 0 ) {
?>
<?php
$targetStartDate = $eCart1->DisplayInfo("startDate");
$targetEndDate = $eCart1->DisplayInfo("endDate");
// rule check
if ($targetEndDate >= $startDate && $targetStartDate <= $endDate) {
$rule = 1;
break; }
?>
<?php
$eCart1->MoveNext();
}
$eCart1->MoveFirst();
?>
<?php if ($rule == 1) { ?>
<div class="errorGroup"><strong>Potential Problem in your Order </strong><br>
Please confirm that you are not purchasing items with overlapping date ranges.
</div>
<?php } ?>
<?php // close conditional if >1 items in cart
} ?>
The rule check always returns a true (1) even when the available candidates do not meet the requirements to fire the rule.