coupon management in order and cart process

This commit is contained in:
Etienne Roudeix
2013-12-19 14:17:22 +01:00
parent c981102d3a
commit d7c1ecf09a
8 changed files with 124 additions and 28 deletions

View File

@@ -82,15 +82,8 @@ class CouponManager
if (count($this->coupons) > 0) {
$couponsKept = $this->sortCoupons($this->coupons);
$isRemovingPostage = $this->isCouponRemovingPostage($couponsKept);
$discount = $this->getEffect($couponsKept);
if ($isRemovingPostage) {
$postage = $this->facade->getCheckoutPostagePrice();
$discount += $postage;
}
// Just In Case test
$checkoutTotalPrice = $this->facade->getCartTotalPrice();
if ($discount >= $checkoutTotalPrice) {
@@ -103,23 +96,24 @@ class CouponManager
/**
* Check if there is a Coupon removing Postage
*
* @param array $couponsKept Array of CouponInterface sorted
*
* @return bool
*/
protected function isCouponRemovingPostage(array $couponsKept)
public function isCouponRemovingPostage()
{
$isRemovingPostage = false;
if (count($this->coupons) == 0) {
return false;
}
$couponsKept = $this->sortCoupons($this->coupons);
/** @var CouponInterface $coupon */
foreach ($couponsKept as $coupon) {
if ($coupon->isRemovingPostage()) {
$isRemovingPostage = true;
return true;
}
}
return $isRemovingPostage;
return false;
}
/**