Skip to content

Commit

Permalink
Merge pull request #84 from mdevaud/fix/clear-specific-coupon
Browse files Browse the repository at this point in the history
fix: fix cart price update on CouponController::clearCoupon()
  • Loading branch information
zawaze authored Mar 29, 2024
2 parents 69b3a3c + 8669a1c commit 1cec47c
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
2 changes: 1 addition & 1 deletion Config/module.xml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
<language>en_US</language>
<language>fr_FR</language>
</languages>
<version>2.2.18</version>
<version>2.2.19</version>
<authors>
<author>
<name>Vincent Lopes-Vicente</name>
Expand Down
15 changes: 15 additions & 0 deletions Controller/Front/CouponController.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
use Thelia\Core\HttpFoundation\Request;
use Thelia\Core\HttpFoundation\Session\Session;
use Thelia\Core\Translation\Translator;
use Thelia\Coupon\CouponManager;
use Thelia\Exception\UnmatchableConditionException;
use Thelia\Model\CouponQuery;

Expand Down Expand Up @@ -160,6 +161,7 @@ public function clearCoupon(
EventDispatcherInterface $dispatcher,
ModelFactory $modelFactory,
Session $session,
CouponManager $couponManager,
$id
) {
$cart = $session->getSessionCart($dispatcher);
Expand All @@ -176,6 +178,19 @@ public function clearCoupon(
unset($consumedCoupons[$coupon->getCode()]);

$session->setConsumedCoupons($consumedCoupons);


$discount = $couponManager->getDiscount();

$session
->getSessionCart($dispatcher)
->setDiscount($discount)
->save();

$session
->getOrder()
->setDiscount($discount);

} catch (Exception $e) {
throw new Exception(Translator::getInstance()->trans('An error occurred while clearing coupon ' . $id . ' : ') . $e->getMessage());
}
Expand Down

0 comments on commit 1cec47c

Please sign in to comment.