WIP Coupon
Refactor : creating dedicated reusable module for Constraints Adding ConstraintManager Secured : - Effects : RemoveXPercent + RemoveXAmount - Validators : all except ModelParam (need CustomerModelParam, AreaModelParam, CountryModelParam ?) - Conditions : AvailableForTotalAmount
This commit is contained in:
@@ -168,12 +168,9 @@ abstract class CouponAbstract implements CouponInterface
|
||||
* Return effects generated by the coupon
|
||||
* A negative value
|
||||
*
|
||||
* @param CouponAdapterInterface $adapter allowing to gather
|
||||
* all necessary Thelia variables
|
||||
*
|
||||
* @return float Amount removed from the Total Checkout
|
||||
*/
|
||||
public function getDiscount(CouponAdapterInterface $adapter)
|
||||
public function getDiscount()
|
||||
{
|
||||
return $this->amount;
|
||||
}
|
||||
|
||||
@@ -88,16 +88,13 @@ interface CouponInterface
|
||||
* A positive value
|
||||
*
|
||||
* Effects could also affect something else than the final Checkout price
|
||||
* CouponAdapter could be use to directly pass a Session value
|
||||
* CouponAdapter $adapter could be use to directly pass a Session value
|
||||
* some would wish to modify
|
||||
* Hence affecting a wide variety of Thelia elements
|
||||
*
|
||||
* @param CouponAdapterInterface $adapter allowing to gather
|
||||
* all necessary Thelia variables
|
||||
*
|
||||
* @return float Amount removed from the Total Checkout
|
||||
*/
|
||||
public function getDiscount(CouponAdapterInterface $adapter);
|
||||
public function getDiscount();
|
||||
|
||||
/**
|
||||
* Return condition to validate the Coupon or not
|
||||
|
||||
@@ -92,14 +92,11 @@ class RemoveXPercent extends CouponAbstract
|
||||
* Return effects generated by the coupon
|
||||
* A negative value
|
||||
*
|
||||
* @param CouponAdapterInterface $adapter allowing to gather
|
||||
* all necessary Thelia variables
|
||||
*
|
||||
* @throws \Thelia\Exception\MissingAdapterException
|
||||
* @throws \InvalidArgumentException
|
||||
* @return float
|
||||
*/
|
||||
public function getDiscount(CouponAdapterInterface $adapter)
|
||||
public function getDiscount()
|
||||
{
|
||||
if ($this->percent >= 100) {
|
||||
throw new \InvalidArgumentException(
|
||||
@@ -107,7 +104,7 @@ class RemoveXPercent extends CouponAbstract
|
||||
);
|
||||
}
|
||||
|
||||
$basePrice = $adapter->getCartTotalPrice();
|
||||
$basePrice = $this->adapter->getCartTotalPrice();
|
||||
|
||||
return $basePrice * (( $this->percent ) / 100);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user