public function perform(PromotionSubjectInterface $subject) { if ($this->isValid()) { $discountedTotal = $subject->getOrderTotal() - $this->amount; if ($discountedTotal < 0) { // Modify amount to make the order total non-negative and stop at 0. $this->amount -= abs($discountedTotal); } $subject->addOrderDiscount($this->amount); } }
public function getValidationResult(PromotionSubjectInterface $subject) { return version_compare($subject->getOrderTotal(), $this->value, $this->operator); }