예제 #1
0
 /**
  * Given a cart and a coupon, returns the real value of the coupon
  *
  * @param CartInterface   $cart   Abstract Cart object
  * @param CouponInterface $coupon Coupon
  *
  * @return MoneyInterface Coupon price
  */
 protected function getPriceCoupon(CartInterface $cart, CouponInterface $coupon)
 {
     $currency = $this->currencyWrapper->getCurrency();
     switch ($coupon->getType()) {
         case ElcodiCouponTypes::TYPE_AMOUNT:
             $amount = $coupon->getPrice();
             return $this->currencyConverter->convertMoney($amount, $currency);
         case ElcodiCouponTypes::TYPE_PERCENT:
             $couponPercent = $coupon->getDiscount();
             return $cart->getProductAmount()->multiply($couponPercent / 100);
     }
 }