Find if dynamic value exists in cart
HI,
I am presenting a popup page with some items to add to the cart that are reduced in price based on the particular item the customer has first added to the cart.
E.G. The customer adds a couch to the cart and because of that he gets a popup with reduced prices on some recommended cushions that he can then add to the cart also.
The problem I have is that the customer could add the reduced price item to the cart from the popup and then delete the original that enabled the reduced price items in the first place.
So therefore, I wish to hide the delete checkbox for the original item as long as an associated reduced price item is in the cart. (Based on the presence of a special "RecID" field I have set up in the cart to associate the original item's ID with the reduced price item.
The customer will be offered more than one reduced price item per Original Item.
The method I have set up so far that works for one reduced price item only in the cart is:
**********************
<td class="eC_FormItem">
<?php if (($eCart1->DisplayInfo("ID")) != ($eCart1->ConditionalTotal("RecID"))) { ?>
<input type="checkbox" value="<?php echo $eCart1->DisplayInfo("ID"); ?>" name="eCart1_Delete_<?php echo $eCart1->DisplayInfo("WAUID"); ?>" />
<?php } ?>
</td>
***********************
RecID is the field in the reduced price item Add To Cart Button that contains the ID of the original item, so the cart needs to be scanned to see if the RecID matching the original item ID is in the cart..
The customer can delete the original item if he deletes the reduced price item first, because then the delete checkbox will again be visible.
The above code works well but fails when an additional reduced price item is added, because $eCart1->ConditionalTotal("RecID") sums the RecID items in the cart.
Say the original item ID is 6, and each "reduced price item" added has a RecID value of 6.
If two "reduced price items" are added, the RecID sums to 12 and so fails.
So is there an eCart operator that can scan the RecID fields in the cart to find if a value exists without summing them.
I thought I might find something that works similarly to ($eCart1->InCart("6") == true) to enable finding a dynamic value in a cart field.
I hope I have explained this well enough.
I thank you in advance for your time.