/** * Calculates coupons price given actual Cart. * * @param CartInterface $cart Cart */ public function refreshCouponAmount(CartInterface $cart) { $couponAmount = Money::create(0, $this->currencyWrapper->get()); $coupons = $this->cartCouponManager->getCoupons($cart); foreach ($coupons as $coupon) { $currentCouponAmount = $this->cartCouponApplicatorCollector->getCouponAbsoluteValue($cart, $coupon); $coupon->setAbsolutePrice($currentCouponAmount); $couponAmount = $couponAmount->add($currentCouponAmount); } $cart->setCouponAmount($couponAmount); }
/** * Given a cart and a coupon, returns the real value of the coupon. * If the type of the coupon is not valid, then an empty Money instance will * be returned, with value 0. * * @deprecated since version 1.1.0, to be removed in 2.0.0. Use * CartCouponApplicatorCollector::getCouponAbsoluteValue * instead. * * @param CartInterface $cart Abstract Cart object * @param CouponInterface $coupon Coupon * * @return MoneyInterface Coupon price */ public function getCouponAbsolutePrice(CartInterface $cart, CouponInterface $coupon) { return $this->cartCouponApplicatorCollector->getCouponAbsoluteValue($cart, $coupon); }