
Originally Posted by
bigduffeye
i just need an extra conditional statement but im kind of stuggling. (hopefully you can help)
i also want to be able to select if a module displays depending on the products in the cart and if they have a certain db field populated.
eg - if both the items in the cart have certain data in db field in the products table, then only show the module.
hope this makes some kind of sense
How about something like:
Code:
$this->enabled = false; // disable by default
$matches = 0 ;
$myorder = $_SESSION['cart']->get_products();
// loop through cart extracting productIDs (or whatever).
for($index = 0 ; $index < count($myorder) ; $index++ ) {
$field = $myorder[$index]['id'] ; // (adapt 'id' to suit the field of interest)
if("$field" == "Data_To_match") $matches++ ; // adapt "Data_To_match" to suit what you are looking for
}
if ($matches == count($myorder)) $this->enabled = true; // Only enable if all products in the cart have a matching $id field. IOW, the number of matches == the number of products.
Note: This code is untested.
Tip: If unsure of the field names, add the following line of code after the $myorder = $_SESSION['cart']->get_products() line:
print_r($myorder) ; exit ;
The output won't be pretty, but it should be clear enough to see exactly what is in the array.
Cheers
Rod