MAJ en Thelia 2.3.4
This commit is contained in:
@@ -8,6 +8,8 @@ use Symfony\Component\EventDispatcher\EventDispatcherInterface;
|
||||
use Thelia\Core\Event\Cart\CartItemDuplicationItem;
|
||||
use Thelia\Core\Event\TheliaEvents;
|
||||
use Thelia\Model\Base\Cart as BaseCart;
|
||||
use Thelia\Model\Country;
|
||||
use Thelia\Model\State;
|
||||
|
||||
class Cart extends BaseCart
|
||||
{
|
||||
@@ -110,8 +112,9 @@ class Cart extends BaseCart
|
||||
*
|
||||
* /!\ The postage amount is not available so it's the total with or without discount an without postage
|
||||
*
|
||||
* @param Country $country
|
||||
* @param bool $discount
|
||||
* @param Country $country
|
||||
* @param bool $discount
|
||||
* @param State|null $state
|
||||
* @return float|int
|
||||
*/
|
||||
public function getTaxedAmount(Country $country, $discount = true, State $state = null)
|
||||
@@ -124,6 +127,7 @@ class Cart extends BaseCart
|
||||
|
||||
if ($discount) {
|
||||
$total -= $this->getDiscount();
|
||||
|
||||
if ($total < 0) {
|
||||
$total = 0;
|
||||
}
|
||||
@@ -135,7 +139,7 @@ class Cart extends BaseCart
|
||||
/**
|
||||
*
|
||||
* @see getTaxedAmount same as this method but the amount is without taxes
|
||||
* @param bool $discount
|
||||
* @param bool $discount
|
||||
* @return float|int
|
||||
*/
|
||||
public function getTotalAmount($discount = true)
|
||||
@@ -144,13 +148,19 @@ class Cart extends BaseCart
|
||||
|
||||
foreach ($this->getCartItems() as $cartItem) {
|
||||
$subtotal = $cartItem->getRealPrice();
|
||||
|
||||
$subtotal *= $cartItem->getQuantity();
|
||||
|
||||
$total += $subtotal;
|
||||
}
|
||||
|
||||
if ($discount) {
|
||||
// discount value is taxed see ISSUE #1476
|
||||
$total -= $this->getDiscount();
|
||||
|
||||
if ($total < 0) {
|
||||
$total = 0;
|
||||
}
|
||||
}
|
||||
|
||||
return $total;
|
||||
@@ -162,7 +172,7 @@ class Cart extends BaseCart
|
||||
*/
|
||||
public function getTotalVAT($taxCountry, $taxState = null)
|
||||
{
|
||||
return ($this->getTaxedAmount($taxCountry) - $this->getTotalAmount());
|
||||
return ($this->getTaxedAmount($taxCountry, true, $taxState) - $this->getTotalAmount(true));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user