Working adding decrementation when coupon is consumed

This commit is contained in:
gmorel
2013-10-22 23:04:08 +02:00
parent b45fbef2ad
commit 52e471ab1b
4 changed files with 37 additions and 5 deletions

View File

@@ -35,6 +35,7 @@ use Thelia\Coupon\CouponManager;
use Thelia\Coupon\ConditionCollection;
use Thelia\Coupon\Type\CouponInterface;
use Thelia\Model\Coupon as CouponModel;
use Thelia\Model\CouponQuery;
/**
* Created by JetBrains PhpStorm.
@@ -120,8 +121,12 @@ class Coupon extends BaseAction implements EventSubscriberInterface
$request->getSession()->setConsumedCoupons($consumedCoupons);
$totalDiscount = $couponManager->getDiscount();
// @todo insert false product in cart with the name of the coupon and the discount as negative price
// @todo decrement coupon quantity
// Decrement coupon quantity
$couponQuery = CouponQuery::create();
$couponModel = $couponQuery->findOneByCode($coupon->getCode());
$couponManager->decrementeQuantity($couponModel);
$request->getSession()->getCart()->setDiscount($totalDiscount);