Do not allow to cumulate the coupon many times. Fix #217
This commit is contained in:
@@ -136,24 +136,26 @@ class Coupon extends BaseAction implements EventSubscriberInterface
|
|||||||
$consumedCoupons = array();
|
$consumedCoupons = array();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Prevent accumulation of the same Coupon on a Checkout
|
if (!isset($consumedCoupons[$event->getCode()])) {
|
||||||
$consumedCoupons[$event->getCode()] = $event->getCode();
|
// Prevent accumulation of the same Coupon on a Checkout
|
||||||
|
$consumedCoupons[$event->getCode()] = $event->getCode();
|
||||||
|
|
||||||
$this->request->getSession()->setConsumedCoupons($consumedCoupons);
|
$this->request->getSession()->setConsumedCoupons($consumedCoupons);
|
||||||
|
|
||||||
$totalDiscount = $this->couponManager->getDiscount();
|
$totalDiscount = $this->couponManager->getDiscount();
|
||||||
|
|
||||||
$this->request
|
$this->request
|
||||||
->getSession()
|
->getSession()
|
||||||
->getCart()
|
->getCart()
|
||||||
->setDiscount($totalDiscount)
|
->setDiscount($totalDiscount)
|
||||||
->save();
|
->save();
|
||||||
$this->request
|
$this->request
|
||||||
->getSession()
|
->getSession()
|
||||||
->getOrder()
|
->getOrder()
|
||||||
->setDiscount($totalDiscount)
|
->setDiscount($totalDiscount)
|
||||||
// ->save()
|
// ->save()
|
||||||
;
|
;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -103,8 +103,8 @@ class RemoveXPercent extends CouponAbstract
|
|||||||
'Percentage must be inferior to 100'
|
'Percentage must be inferior to 100'
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
$taxCountry = $this->facade->getContainer()->get('thelia.taxEngine')->getDeliveryCountry();
|
||||||
$basePrice = $this->facade->getCartTotalPrice();
|
$basePrice = $this->facade->getCart()->getTaxedAmount($taxCountry);
|
||||||
|
|
||||||
return round($basePrice * $this->percentage/100, 2);
|
return round($basePrice * $this->percentage/100, 2);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -76,17 +76,10 @@ class Cart extends BaseCart
|
|||||||
|
|
||||||
public function getTaxedAmount(Country $country)
|
public function getTaxedAmount(Country $country)
|
||||||
{
|
{
|
||||||
$taxCalculator = new Calculator();
|
|
||||||
|
|
||||||
$total = 0;
|
$total = 0;
|
||||||
|
|
||||||
foreach($this->getCartItems() as $cartItem) {
|
foreach($this->getCartItems() as $cartItem) {
|
||||||
$subtotal = $cartItem->getRealPrice();
|
$total += $cartItem->getRealTaxedPrice($country) * $cartItem->getQuantity();
|
||||||
/* 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();
|
$total -= $this->getDiscount();
|
||||||
|
|||||||
@@ -94,6 +94,11 @@ class CartItem extends BaseCartItem
|
|||||||
return $this->getPromo() == 1 ? $this->getPromoPrice() : $this->getPrice();
|
return $this->getPromo() == 1 ? $this->getPromoPrice() : $this->getPrice();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getRealTaxedPrice(Country $country)
|
||||||
|
{
|
||||||
|
return $this->getPromo() == 1 ? $this->getTaxedPromoPrice($country) : $this->getTaxedPrice($country);
|
||||||
|
}
|
||||||
|
|
||||||
public function getTaxedPrice(Country $country)
|
public function getTaxedPrice(Country $country)
|
||||||
{
|
{
|
||||||
$taxCalculator = new Calculator();
|
$taxCalculator = new Calculator();
|
||||||
|
|||||||
0
local/modules/Colissimo/Config/thelia.sql
Normal file → Executable file
0
local/modules/Colissimo/Config/thelia.sql
Normal file → Executable file
@@ -266,7 +266,6 @@
|
|||||||
{loop type="payment" name="payments" force_return="true"}
|
{loop type="payment" name="payments" force_return="true"}
|
||||||
|
|
||||||
{assign "paymentModuleId" $ID}
|
{assign "paymentModuleId" $ID}
|
||||||
|
|
||||||
{loop type="image" name="paymentspicture" source="module" source_id=$ID force_return="true" width="100" height="72"}
|
{loop type="image" name="paymentspicture" source="module" source_id=$ID force_return="true" width="100" height="72"}
|
||||||
|
|
||||||
<li>
|
<li>
|
||||||
|
|||||||
Reference in New Issue
Block a user