/** * Work out the total discountable amount for a given discount * * @param Discount * * @return float */ protected function getDiscountableAmount($discount) { $amount = 0; foreach ($this->order->Items() as $item) { if (\ItemDiscountConstraint::match($item, $discount)) { $amount += method_exists($item, "DiscountableAmount") ? $item->DiscountableAmount() : $item->Total(); } } return $amount; }
/** * Checks if the given item qualifies for a discount. * * @param ItemPriceInfo $info * @return boolean */ protected function itemQualifies(ItemPriceInfo $info) { return ItemDiscountConstraint::match($info->getItem(), $this->discount); }