Best eCart practice recommendation
Hello,
I’ d like a suggestion on best practices to check for a product intersection.
Our products have a StartDate and an EndDate saved as a Unix TimeStamp.
The logic for checking if an intersection exists is as follows:
if ($targetEndDate >= $startDate && $targetStartDate <= $endDate)
{
$showMe = 'trueness';
}
else
{
$showMe = 'false';
}
Our Product page has all the products listed so firing off the validation check on the Product page could be one solution.
The Add to Cart button takes us to the Cart page which looks like an equally viable page to use for checking if there is a clash.
My original logic is to take the first item set to the cart and establish a startDate and endDate, then each newly added product would run the conditional statement as the targetStartDate and targetEndDate. IF an intersection is present we show an alert (show region).
Validation on the Product page would have to block the adding of a new product that clashes but would make it more difficult to remove one item and select another.
Validation on the Cart page seems like it may be the best location to check for clashes but since there is no recordset and the eCart values are sessions, it seems I’d need to pull the productIds from the Session values and then do a comparison.
Before I start programming this , are their any suggestions on the best practices to achieve this goal in eCart (6)?