Is item value in cart?
First off - I've got a working solution - just doesn't seem very elegant and would be nice to find a generic way to do it, as this test comes up a lot.
Client wishes to return user to a specific page, if a certain item (from a particular product category) is removed from the cart (so the only option is to make a purchase from a particular product group)
I join my product_category and products tables together, so each product
has a category, and that category has a 'Required' 1 or 0 flag
<?php echo $row_rs_products_joined_with_categories['CategoryReqFlag']; ?>
which is added to the cart item ProductCategoryReqFlag
at the same time the product is added to the cart
Q:
what is the most elegant way to test for this value
and go to the page that is set up as CONTINUE shopping
so far have this
<?php
$i=0;
$flags=array();
$target=1;
while (!$eCart1->EOF())
{
$flags[$i]=$eCart1->DisplayInfo("ProductCategoryReqFlag");
$i++;
$eCart1->MoveNext();
}
$eCart1->MoveFirst();
if (!in_array($target, $flags))
{
$eCart1->redirStr = "index.php?id_sec=62";
$eCart1->cartAction = "RedirectIfEmpty"; // just putting $eCart1->cartAction = "Continue"; doesn't work?
}
?>
PS - I don't want to test for a specific ID in Cart
think we are looking for a function something like
function InCartVal($ItemProperty) {
******
******
******
}