public function applyDiscount(OrderableInterface $order) { $customer = $order->getCustomer(); if (!$customer->getLoyaltyCardNumber()) { throw $this->createCouponException('Coupon is reserved to loyal customers.'); } return $this->coupon->applyDiscount($order); }
public function applyDiscount(OrderableInterface $order) { $customer = $order->getCustomer(); if ($customer->hasPastOrders()) { throw $this->createCouponException('Customer already has past orders.'); } return $this->coupon->applyDiscount($order); }
public function applyDiscount(OrderableInterface $order) { $amount = $order->getTotalAmount(); if ($amount->lessThan($this->minimumAmount)) { throw $this->createCouponException(sprintf('Coupon requires a minimum amount of %u.', $this->minimumAmount->getAmount())); } return $this->coupon->applyDiscount($order); }
public function applyDiscount(OrderableInterface $order) { $quantity = $order->getQuantity(); if ($quantity < $this->minimumQuantity) { throw $this->createCouponException(sprintf('Minimum quantity of %u is required.', $this->minimumQuantity)); } return $this->coupon->applyDiscount($order); }
public function applyDiscount(OrderableInterface $order) { $amount = $order->getTotalAmount(); return $amount->subtract($amount->multiply($this->rate)); }