From 39ff464319355c7c752d842bf72817d2e890b5f8 Mon Sep 17 00:00:00 2001 From: Franck Allimant Date: Tue, 10 Jun 2014 15:59:36 +0200 Subject: [PATCH] Order total may be calculated with or without discounted items --- core/lib/Thelia/Coupon/BaseFacade.php | 26 ++++++++++++++++++++++---- 1 file changed, 22 insertions(+), 4 deletions(-) diff --git a/core/lib/Thelia/Coupon/BaseFacade.php b/core/lib/Thelia/Coupon/BaseFacade.php index 0fdf0c36b..5794df673 100644 --- a/core/lib/Thelia/Coupon/BaseFacade.php +++ b/core/lib/Thelia/Coupon/BaseFacade.php @@ -118,17 +118,35 @@ class BaseFacade implements FacadeInterface * * @return float */ - public function getCartTotalPrice() + public function getCartTotalPrice($withItemsInPromo = true) { - return $this->getRequest()->getSession()->getCart()->getTotalAmount(); + $total = 0; + $cartItems = $this->getRequest()->getSession()->getCart()->getCartItems(); + + foreach ($cartItems as $cartItem) { + if ($withItemsInPromo || ! $cartItem->getPromo()) { + $total += $cartItem->getRealPrice() * $cartItem->getQuantity(); + } + } + + return $total; } - public function getCartTotalTaxPrice() + public function getCartTotalTaxPrice($withItemsInPromo = true) { $taxCountry = $this->getContainer()->get('thelia.taxEngine')->getDeliveryCountry(); + $cartItems = $this->getRequest()->getSession()->getCart()->getCartItems(); - return $this->getCart()->getTaxedAmount($taxCountry, false); + $total = 0; + + foreach ($cartItems as $cartItem) { + if ($withItemsInPromo || ! $cartItem->getPromo()) { + $total += $cartItem->getRealTaxedPrice($taxCountry) * $cartItem->getQuantity(); + } + } + + return $total; } /**