I have the following example array:
$comparisons = array(
0 => array(
'method' => 'productTotalQuantity',
'operator' => '>=',
'value' => '2'
),
1 => array(
'method' => 'productTotalWeight',
'operator' => '<=',
'value' => '10'
)
);
I have invented this array structure, so it can be altered if required. I am trying to somehow evaluate the operator key, so that I can achieve something along the lines of:
foreach ($comparisons as $comparison) {
$value = $this->$comparison['method']($product);
// E.g. $value = $this->productTotalQuantity($product)
// $value could = 4
if ($value $comparison['operator'] $comparison['value']) {
// Comparison successful
$matches[] = TRUE;
}
}
if (count($matches) == count($comparisons)) {
// All comparisons were successful. Apply the discount.
}
If you have time, a full code example of how to parse this array would be extremely helpful. I've been working on it for about 20 hours straight and think I'm about to literally bash my head against a brick wall. If you are familiar with Magento, I am trying to somewhat mimic the functionality of the "Shopping Cart Price Rule" Conditions in Promotions.