/** * Match a rule to the item * * @author Jonathan Davis * @since 1.1 * * @param array $rule A structured rule array * @return boolean **/ public function match($rule) { extract($rule); switch ($property) { case 'Any item name': $subject = $this->name; break; case 'Any item quantity': $subject = (int) $this->quantity; break; case 'Any item amount': $subject = $this->total; break; case 'Name': $subject = $this->name; break; case 'Category': $subject = $this->categories; break; case 'Tag name': $subject = $this->tags; break; case 'Variation': $subject = $this->option->label; break; case 'Input name': foreach ($this->data as $inputName => $inputValue) { if (ShoppPromo::match_rule($inputName, $logic, $value, $property)) { return true; } } return false; case 'Input value': foreach ($this->data as $inputName => $inputValue) { if (ShoppPromo::match_rule($inputValue, $logic, $value, $property)) { return true; } } return false; case 'Quantity': $subject = $this->quantity; break; case 'Unit price': $subject = $this->unitprice; break; case 'Total price': $subject = $this->total; break; case 'Discount amount': $subject = $this->discount; break; } return ShoppPromo::match_rule($subject, $logic, $value, $property); }