coupons effect are recalculated after each product's cart modification. Fix #237

This commit is contained in:
Manuel Raynaud
2014-03-03 17:40:54 +01:00
parent c30abacfbc
commit 06539ad9bf
7 changed files with 32 additions and 8 deletions

View File

@@ -161,6 +161,22 @@ class Coupon extends BaseAction implements EventSubscriberInterface
$event->setDiscount($totalDiscount);
}
public function updateOrderDiscount($event)
{
$discount = $this->couponManager->getDiscount();
$this->request
->getSession()
->getCart()
->setDiscount($discount)
->save();
$this->request
->getSession()
->getOrder()
->setDiscount($discount);
}
/**
* Call the Model and delegate the create or delete action
* Feed the Event with the updated model
@@ -310,6 +326,9 @@ class Coupon extends BaseAction implements EventSubscriberInterface
TheliaEvents::COUPON_CONDITION_UPDATE => array("updateCondition", 128),
TheliaEvents::ORDER_SET_POSTAGE => array("testFreePostage", 256),
TheliaEvents::ORDER_BEFORE_PAYMENT => array("afterOrder", 128),
TheliaEvents::CART_ADDITEM => array("updateOrderDiscount", 10),
TheliaEvents::CART_UPDATEITEM => array("updateOrderDiscount", 10),
TheliaEvents::CART_DELETEITEM => array("updateOrderDiscount", 10),
);
}
}