cart integration
This commit is contained in:
@@ -8,6 +8,7 @@ use Thelia\Model\Base\Cart as BaseCart;
|
||||
use Thelia\Model\ProductSaleElementsQuery;
|
||||
use Thelia\Model\ProductPriceQuery;
|
||||
use Thelia\Model\CartItemQuery;
|
||||
use Thelia\TaxEngine\Calculator;
|
||||
|
||||
class Cart extends BaseCart
|
||||
{
|
||||
@@ -72,9 +73,25 @@ class Cart extends BaseCart
|
||||
;
|
||||
}
|
||||
|
||||
public function getTaxedAmount()
|
||||
public function getTaxedAmount(Country $country)
|
||||
{
|
||||
$taxCalculator = new Calculator();
|
||||
|
||||
$total = 0;
|
||||
|
||||
foreach($this->getCartItems() as $cartItem) {
|
||||
$subtotal = $cartItem->getRealPrice();
|
||||
$subtotal -= $cartItem->getDiscount();
|
||||
/* we round it for the unit price, before the quantity factor */
|
||||
$subtotal = round($taxCalculator->load($cartItem->getProduct(), $country)->getTaxedPrice($subtotal), 2);
|
||||
$subtotal *= $cartItem->getQuantity();
|
||||
|
||||
$total += $subtotal;
|
||||
}
|
||||
|
||||
$total -= $this->getDiscount();
|
||||
|
||||
return $total;
|
||||
}
|
||||
|
||||
public function getTotalAmount()
|
||||
@@ -82,7 +99,11 @@ class Cart extends BaseCart
|
||||
$total = 0;
|
||||
|
||||
foreach($this->getCartItems() as $cartItem) {
|
||||
$total += $cartItem->getPrice()-$cartItem->getDiscount();
|
||||
$subtotal = $cartItem->getRealPrice();
|
||||
$subtotal -= $cartItem->getDiscount();
|
||||
$subtotal *= $cartItem->getQuantity();
|
||||
|
||||
$total += $subtotal;
|
||||
}
|
||||
|
||||
$total -= $this->getDiscount();
|
||||
|
||||
@@ -65,6 +65,11 @@ class CartItem extends BaseCartItem
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getRealPrice()
|
||||
{
|
||||
return $this->getPromo() == 1 ? $this->getPromoPrice() : $this->getPrice();
|
||||
}
|
||||
|
||||
public function getTaxedPrice(Country $country)
|
||||
{
|
||||
$taxCalculator = new Calculator();
|
||||
|
||||
Reference in New Issue
Block a user