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 993be2f37a
commit 39ff464319

View File

@@ -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;
}
/**