Order total may be calculated with or without discounted items

This commit is contained in:
Franck Allimant
2014-06-10 15:59:36 +02:00
parent a1eeddc51b
commit 80653fee0b

View File

@@ -118,17 +118,35 @@ class BaseFacade implements FacadeInterface
* *
* @return float * @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(); $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;
} }
/** /**