WIP Coupon

Refactor
This commit is contained in:
gmorel
2013-08-23 20:00:32 +02:00
parent 73677b7c1a
commit eae86cd797
50 changed files with 1723 additions and 676 deletions

View File

@@ -23,6 +23,9 @@
namespace Thelia\Coupon;
use Thelia\Coupon\Type\CouponInterface;
use Thelia\Model\Coupon;
/**
* Created by JetBrains PhpStorm.
* Date: 8/19/13
@@ -93,4 +96,22 @@ interface CouponAdapterInterface
*/
public function getCurrentCoupons();
/**
* Find one Coupon in the database from its code
*
* @param string $code Coupon code
*
* @return Coupon
*/
public function findOneCouponByCode($code);
/**
* Save a Coupon in the database
*
* @param CouponInterface $coupon Coupon
*
* @return $this
*/
public function saveCoupon(CouponInterface $coupon);
}

View File

@@ -23,6 +23,10 @@
namespace Thelia\Coupon;
use Thelia\Coupon\Type\CouponInterface;
use Thelia\Model\Coupon;
use Thelia\Model\CouponQuery;
/**
* Created by JetBrains PhpStorm.
* Date: 8/19/13
@@ -30,6 +34,7 @@ namespace Thelia\Coupon;
*
* @package Coupon
* @author Guillaume MOREL <gmorel@openstudio.fr>
* @todo implements
*
*/
class CouponBaseAdapter implements CouponAdapterInterface
@@ -111,7 +116,7 @@ class CouponBaseAdapter implements CouponAdapterInterface
*/
public function getCurrentCoupons()
{
$couponFactory = new CouponFactory();
$couponFactory = new CouponFactory($this);
// @todo Get from Session
$couponCodes = array('XMAS', 'SPRINGBREAK');
@@ -124,5 +129,46 @@ class CouponBaseAdapter implements CouponAdapterInterface
return $coupons;
}
/**
* Find one Coupon in the database from its code
*
* @param string $code Coupon code
*
* @return Coupon
*/
public function findOneCouponByCode($code)
{
$couponQuery = CouponQuery::create();
return $couponQuery->findOneByCode($code);
}
/**
* Save a Coupon in the database
*
* @param CouponInterface $coupon Coupon
*
* @return $this
*/
public function saveCoupon(CouponInterface $coupon)
{
// $couponModel = new Coupon();
// $couponModel->setCode($coupon->getCode());
// $couponModel->setType(get_class($coupon));
// $couponModel->setTitle($coupon->getTitle());
// $couponModel->setShortDescription($coupon->getShortDescription());
// $couponModel->setDescription($coupon->getDescription());
// $couponModel->setAmount($coupon->getEffect());
// $couponModel->setIsUsed(0);
// $couponModel->setIsEnabled(1);
// $couponModel->set
// $couponModel->set
// $couponModel->set
// $couponModel->set
// $couponModel->set
// $couponModel->set
// $couponModel->set
}
}

View File

@@ -23,13 +23,12 @@
namespace Thelia\Coupon;
use Symfony\Component\Translation\Exception\NotFoundResourceException;
use Thelia\Coupon\Type\CouponInterface;
use Thelia\Coupon\Type\RemoveXAmount;
use Thelia\Model\Base\CouponQuery;
use Thelia\Exception\CouponExpiredException;
use Thelia\Model\Coupon;
use Symfony\Component\Serializer\Serializer;
use Symfony\Component\Serializer\Encoder\JsonEncoder;
use Symfony\Component\Serializer\Normalizer\GetSetMethodNormalizer;
/**
* Created by JetBrains PhpStorm.
@@ -44,18 +43,41 @@ use Symfony\Component\Serializer\Normalizer\GetSetMethodNormalizer;
*/
class CouponFactory
{
/** @var CouponAdapterInterface Provide necessary value from Thelia*/
protected $adapter;
/**
* Constructor
*
* @param CouponAdapterInterface $adapter Provide necessary value from Thelia
*/
function __construct(CouponAdapterInterface $adapter)
{
$this->adapter = $adapter;
}
/**
* Build a CouponInterface from its database data
*
* @param string $couponCode Coupon code ex: XMAS
*
* @throws \Thelia\Exception\CouponExpiredException
* @throws \Symfony\Component\Translation\Exception\NotFoundResourceException
* @return CouponInterface ready to be processed
*/
public function buildCouponFromCode($couponCode)
{
/** @var Coupon $couponModel */
$couponModel = $this->adapter->findOneCouponByCode($couponCode);
if ($couponModel === null) {
throw new NotFoundResourceException(
'Coupon ' . $couponCode . ' not found in Database'
);
}
$couponQuery = CouponQuery::create();
$couponModel = $couponQuery->findByCode($couponCode);
if ($couponModel->getExpirationDate() < new \DateTime()) {
throw new CouponExpiredException($couponCode);
}
return $this->buildCouponInterfacFromModel($couponModel);
}
@@ -74,40 +96,25 @@ class CouponFactory
$couponClass = $model->getType();
/** @var CouponInterface $coupon*/
$coupon = new $$couponClass(
$coupon = new $couponClass(
$model->getCode(),
$model->getTitle(),
$model->getShortDescription(),
$model->getDescription(),
$model->getAmount(),
$isCumulative,
$isRemovingPostage
$isRemovingPostage,
$model->getIsAvailableOnSpecialOffers(),
$model->getIsEnabled(),
$model->getMaxUsage(),
$model->getExpirationDate()
);
$normalizer = new GetSetMethodNormalizer();
$encoder = new JsonEncoder();
$serializer = new Serializer(array($normalizer), array($encoder));
$o = new \ArrayObject();
$unserializedRuleTypes = $o->unserialize(
$model->getSerializedRulesType()
);
$unserializedRuleContents = $o->unserialize(
$model->getSerializedRulesContent()
);
$rules = array();
foreach ($unserializedRuleTypes as $key => $unserializedRuleType) {
$rules[] = $serializer->deserialize(
$unserializedRuleContents[$key],
$unserializedRuleType,
'json'
);
}
/** @var CouponRuleCollection $rules */
$rules = unserialize(base64_decode($model->getSerializedRules()));
$coupon->setRules($rules);
return $coupon;
}
}
}

View File

@@ -51,7 +51,7 @@ class CouponManager
*
* @param CouponAdapterInterface $adapter Provide necessary value from Thelia
*/
function __construct($adapter)
function __construct(CouponAdapterInterface $adapter)
{
$this->adapter = $adapter;
$this->coupons = $this->adapter->getCurrentCoupons();
@@ -69,7 +69,7 @@ class CouponManager
$discount = 0.00;
if (count($this->coupons) > 0) {
$couponsKept = $this->sortCoupons();
$couponsKept = $this->sortCoupons($this->coupons);
$isRemovingPostage = $this->isCouponRemovingPostage($couponsKept);
if ($isRemovingPostage) {
@@ -111,17 +111,36 @@ class CouponManager
* Sort Coupon to keep
* Coupon not cumulative cancels previous
*
* @param array $coupons CouponInterface to process
*
* @return array Array of CouponInterface sorted
*/
protected function sortCoupons()
protected function sortCoupons(array $coupons)
{
$couponsKept = array();
/** @var CouponInterface $coupon */
foreach ($this->coupons as $coupon) {
if (!$coupon->isCumulative()) {
$couponsKept = array();
$couponsKept[] = $coupon;
foreach ($coupons as $coupon) {
if (!$coupon->isExpired()) {
if ($coupon->isCumulative()) {
if (isset($couponsKept[0])) {
/** @var CouponInterface $previousCoupon */
$previousCoupon = $couponsKept[0];
if ($previousCoupon->isCumulative()) {
// Add Coupon
$couponsKept[] = $coupon;
} else {
// Reset Coupons, add last
$couponsKept = array($coupon);
}
} else {
// Reset Coupons, add last
$couponsKept = array($coupon);
}
} else {
// Reset Coupons, add last
$couponsKept = array($coupon);
}
}
}

View File

@@ -0,0 +1,88 @@
<?php
/**********************************************************************************/
/* */
/* Thelia */
/* */
/* Copyright (c) OpenStudio */
/* email : info@thelia.net */
/* web : http://www.thelia.net */
/* */
/* This program is free software; you can redistribute it and/or modify */
/* it under the terms of the GNU General Public License as published by */
/* the Free Software Foundation; either version 3 of the License */
/* */
/* This program is distributed in the hope that it will be useful, */
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
/* GNU General Public License for more details. */
/* */
/* You should have received a copy of the GNU General Public License */
/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
/* */
/**********************************************************************************/
namespace Thelia\Coupon;
use Symfony\Component\Serializer\Encoder\JsonEncoder;
use Thelia\Coupon\Rule\CouponRuleInterface;
use Thelia\Exception\InvalidRuleException;
/**
* Created by JetBrains PhpStorm.
* Date: 8/19/13
* Time: 3:24 PM
*
* Manage a set of v
*
* @package Coupon
* @author Guillaume MOREL <gmorel@openstudio.fr>
*
*/
class CouponRuleCollection
{
/** @var array Array of CouponRuleInterface */
protected $rules = array();
/**
* Constructor
*
* @param array $rules Array of CouponRuleInterface
*
* @throws \Thelia\Exception\InvalidRuleException
*/
function __construct(array $rules)
{
foreach ($rules as $rule) {
if (!$rule instanceof CouponRuleInterface) {
throw new InvalidRuleException(get_class());
}
}
$this->rules = $rules;
}
/**
* Get Rules
*
* @return array Array of CouponRuleInterface
*/
public function getRules()
{
return $this->rules;
}
/**
* Add a CouponRuleInterface to the Collection
*
* @param CouponRuleInterface $rule Rule
*
* @return $this
*/
public function add(CouponRuleInterface $rule)
{
$this->rules[] = $rule;
return $this;
}
}

View File

@@ -23,6 +23,8 @@
namespace Thelia\Coupon\Rule;
use Thelia\Coupon\CouponAdapterInterface;
/**
* Created by JetBrains PhpStorm.
* Date: 8/19/13
@@ -34,31 +36,26 @@ namespace Thelia\Coupon\Rule;
*/
class AvailableForDate extends AvailableForPeriod
{
/**
* Generate current Rule validator from adapter
* Check if backoffice inputs are relevant or not
*
* @param CouponAdapterInterface $adapter allowing to gather
* all necessary Thelia variables
*
* @throws \Symfony\Component\Intl\Exception\NotImplementedException
* @return $this
* @return bool
*/
protected function setValidators(CouponAdapterInterface $adapter)
public function checkBackOfficeInput()
{
parent::setValidators($adapter); // TODO: Change the autogenerated stub
// TODO: Implement checkBackOfficeInput() method.
}
/**
* Generate current Rule param to be validated from adapter
* Check if Checkout inputs are relevant or not
*
* @param CouponAdapterInterface $adapter allowing to gather
* all necessary Thelia variables
*
* @throws \Symfony\Component\Intl\Exception\NotImplementedException
* @return $this
* @return bool
*/
protected function setParametersToValidate(CouponAdapterInterface $adapter)
public function checkCheckoutInput()
{
parent::setParametersToValidate($adapter); // TODO: Change the autogenerated stub
// TODO: Implement checkCheckoutInput() method.
}
}

View File

@@ -34,31 +34,26 @@ namespace Thelia\Coupon\Rule;
*/
class AvailableForLocationX extends CouponRuleAbstract
{
/**
* Generate current Rule validator from adapter
* Check if backoffice inputs are relevant or not
*
* @param CouponAdapterInterface $adapter allowing to gather
* all necessary Thelia variables
*
* @throws \Symfony\Component\Intl\Exception\NotImplementedException
* @return $this
* @return bool
*/
protected function setValidators(CouponAdapterInterface $adapter)
public function checkBackOfficeInput()
{
parent::setValidators($adapter); // TODO: Change the autogenerated stub
// TODO: Implement checkBackOfficeInput() method.
}
/**
* Generate current Rule param to be validated from adapter
* Check if Checkout inputs are relevant or not
*
* @param CouponAdapterInterface $adapter allowing to gather
* all necessary Thelia variables
*
* @throws \Symfony\Component\Intl\Exception\NotImplementedException
* @return $this
* @return bool
*/
protected function setParametersToValidate(CouponAdapterInterface $adapter)
public function checkCheckoutInput()
{
parent::setParametersToValidate($adapter); // TODO: Change the autogenerated stub
// TODO: Implement checkCheckoutInput() method.
}
}

View File

@@ -34,31 +34,24 @@ namespace Thelia\Coupon\Rule;
*/
class AvailableForPeriod extends CouponRuleAbstract
{
/**
* Generate current Rule validator from adapter
* Check if backoffice inputs are relevant or not
*
* @param CouponAdapterInterface $adapter allowing to gather
* all necessary Thelia variables
*
* @throws \Symfony\Component\Intl\Exception\NotImplementedException
* @return $this
* @return bool
*/
protected function setValidators(CouponAdapterInterface $adapter)
public function checkBackOfficeInput()
{
parent::setValidators($adapter); // TODO: Change the autogenerated stub
// TODO: Implement checkBackOfficeInput() method.
}
/**
* Generate current Rule param to be validated from adapter
* Check if Checkout inputs are relevant or not
*
* @param CouponAdapterInterface $adapter allowing to gather
* all necessary Thelia variables
*
* @throws \Symfony\Component\Intl\Exception\NotImplementedException
* @return $this
* @return bool
*/
protected function setParametersToValidate(CouponAdapterInterface $adapter)
public function checkCheckoutInput()
{
parent::setParametersToValidate($adapter); // TODO: Change the autogenerated stub
// TODO: Implement checkCheckoutInput() method.
}
}

View File

@@ -34,31 +34,24 @@ namespace Thelia\Coupon\Rule;
*/
class AvailableForRepeatedDate extends AvailableForDate
{
/**
* Generate current Rule validator from adapter
* Check if backoffice inputs are relevant or not
*
* @param CouponAdapterInterface $adapter allowing to gather
* all necessary Thelia variables
*
* @throws \Symfony\Component\Intl\Exception\NotImplementedException
* @return $this
* @return bool
*/
protected function setValidators(CouponAdapterInterface $adapter)
public function checkBackOfficeInput()
{
parent::setValidators($adapter); // TODO: Change the autogenerated stub
// TODO: Implement checkBackOfficeInput() method.
}
/**
* Generate current Rule param to be validated from adapter
* Check if Checkout inputs are relevant or not
*
* @param CouponAdapterInterface $adapter allowing to gather
* all necessary Thelia variables
*
* @throws \Symfony\Component\Intl\Exception\NotImplementedException
* @return $this
* @return bool
*/
protected function setParametersToValidate(CouponAdapterInterface $adapter)
public function checkCheckoutInput()
{
parent::setParametersToValidate($adapter); // TODO: Change the autogenerated stub
// TODO: Implement checkCheckoutInput() method.
}
}

View File

@@ -23,6 +23,8 @@
namespace Thelia\Coupon\Rule;
use Thelia\Coupon\CouponAdapterInterface;
/**
* Created by JetBrains PhpStorm.
* Date: 8/19/13
@@ -34,19 +36,6 @@ namespace Thelia\Coupon\Rule;
*/
class AvailableForRepeatedPeriod extends AvailableForPeriod
{
/**
* Generate current Rule validator from adapter
*
* @param CouponAdapterInterface $adapter allowing to gather
* all necessary Thelia variables
*
* @throws \Symfony\Component\Intl\Exception\NotImplementedException
* @return $this
*/
protected function setValidators(CouponAdapterInterface $adapter)
{
parent::setValidators($adapter); // TODO: Change the autogenerated stub
}
/**
* Generate current Rule param to be validated from adapter
@@ -61,4 +50,24 @@ class AvailableForRepeatedPeriod extends AvailableForPeriod
{
parent::setParametersToValidate($adapter); // TODO: Change the autogenerated stub
}
/**
* Check if backoffice inputs are relevant or not
*
* @return bool
*/
public function checkBackOfficeInput()
{
// TODO: Implement checkBackOfficeInput() method.
}
/**
* Check if Checkout inputs are relevant or not
*
* @return bool
*/
public function checkCheckoutInput()
{
// TODO: Implement checkCheckoutInput() method.
}
}

View File

@@ -166,7 +166,8 @@ class AvailableForTotalAmount extends CouponRuleAbstract
*/
protected function setValidatorsFromAdapter(CouponAdapterInterface $adapter)
{
$adapter->getRule($this);
// $adapter->getRule($this);
// @todo implement
}
/**

View File

@@ -34,31 +34,5 @@ namespace Thelia\Coupon\Rule;
*/
class AvailableForTotalAmountForCategoryY extends AvailableForTotalAmount
{
/**
* Generate current Rule validator from adapter
*
* @param CouponAdapterInterface $adapter allowing to gather
* all necessary Thelia variables
*
* @throws \Symfony\Component\Intl\Exception\NotImplementedException
* @return $this
*/
protected function setValidators(CouponAdapterInterface $adapter)
{
parent::setValidators($adapter); // TODO: Change the autogenerated stub
}
/**
* Generate current Rule param to be validated from adapter
*
* @param CouponAdapterInterface $adapter allowing to gather
* all necessary Thelia variables
*
* @throws \Symfony\Component\Intl\Exception\NotImplementedException
* @return $this
*/
protected function setParametersToValidate(CouponAdapterInterface $adapter)
{
parent::setParametersToValidate($adapter); // TODO: Change the autogenerated stub
}
}

View File

@@ -23,8 +23,6 @@
namespace Thelia\Coupon\Rule;
use Thelia\Type\IntType;
/**
* Created by JetBrains PhpStorm.
* Date: 8/19/13
@@ -38,32 +36,25 @@ use Thelia\Type\IntType;
*/
class AvailableForXArticles extends CouponRuleAbstract
{
/**
* Generate current Rule validator from adapter
* Check if backoffice inputs are relevant or not
*
* @param CouponAdapterInterface $adapter allowing to gather
* all necessary Thelia variables
*
* @throws \Symfony\Component\Intl\Exception\NotImplementedException
* @return $this
* @return bool
*/
protected function setValidators(CouponAdapterInterface $adapter)
public function checkBackOfficeInput()
{
parent::setValidators($adapter); // TODO: Change the autogenerated stub
// TODO: Implement checkBackOfficeInput() method.
}
/**
* Generate current Rule param to be validated from adapter
* Check if Checkout inputs are relevant or not
*
* @param CouponAdapterInterface $adapter allowing to gather
* all necessary Thelia variables
*
* @throws \Symfony\Component\Intl\Exception\NotImplementedException
* @return $this
* @return bool
*/
protected function setParametersToValidate(CouponAdapterInterface $adapter)
public function checkCheckoutInput()
{
parent::setParametersToValidate($adapter); // TODO: Change the autogenerated stub
// TODO: Implement checkCheckoutInput() method.
}
}

View File

@@ -23,8 +23,6 @@
namespace Thelia\Coupon\Rule;
use Thelia\Coupon\CouponAdapterInterface;
/**
* Created by JetBrains PhpStorm.
* Date: 8/19/13

View File

@@ -26,6 +26,7 @@ namespace Thelia\Coupon\Type;
use Symfony\Component\Intl\Exception\NotImplementedException;
use Thelia\Coupon\CouponAdapterInterface;
use Thelia\Coupon\Rule\CouponRuleInterface;
use Thelia\Coupon\CouponRuleCollection;
use Thelia\Coupon\RuleOrganizerInterface;
use Thelia\Exception\InvalidRuleException;
@@ -48,7 +49,7 @@ abstract class CouponAbstract implements CouponInterface
/** @var RuleOrganizerInterface */
protected $organizer = null;
/** @var array Array of CouponRuleInterface */
/** @var CouponRuleCollection Array of CouponRuleInterface */
protected $rules = null;
/** @var string Coupon code (ex: XMAS) */
@@ -63,6 +64,12 @@ abstract class CouponAbstract implements CouponInterface
/** @var string Coupon description */
protected $description = null;
/** @var bool if Coupon is enabled */
protected $isEnabled = false;
/** @var \DateTime Coupon expiration date */
protected $expirationDate = null;
/** @var bool if Coupon is cumulative */
protected $isCumulative = false;
@@ -72,6 +79,12 @@ abstract class CouponAbstract implements CouponInterface
/** @var float Amount that will be removed from the Checkout (Coupon Effect) */
protected $amount = 0;
/** @var int Max time a Coupon can be used (-1 = unlimited) */
protected $maxUsage = -1;
/** @var bool if Coupon is available for Products already on special offers */
protected $isAvailableOnSpecialOffers = false;
/**
* Set Adapter containing all relevant data
*
@@ -176,13 +189,11 @@ abstract class CouponAbstract implements CouponInterface
/**
* Return condition to validate the Coupon or not
*
* @return array An array of CouponRuleInterface
* @return CouponRuleCollection
*/
public function getRules()
{
$arrayObject = new \ArrayObject($this->rules);
return $arrayObject->getArrayCopy();
return clone $this->rules;
}
/**
@@ -195,7 +206,7 @@ abstract class CouponAbstract implements CouponInterface
*/
public function addRule(CouponRuleInterface $rule)
{
$this->rules[] = $rule;
$this->rules->add($rule);
return $this;
}
@@ -204,22 +215,14 @@ abstract class CouponAbstract implements CouponInterface
* Replace the existing Rules by those given in parameter
* If one Rule is badly implemented, no Rule will be added
*
* @param array $rules CouponRuleInterface to add
* @param CouponRuleCollection $rules CouponRuleInterface to add
*
* @return $this
* @throws \Thelia\Exception\InvalidRuleException
*/
public function setRules(array $rules)
public function setRules(CouponRuleCollection $rules)
{
foreach ($rules as $rule) {
if (!$rule instanceof CouponRuleInterface) {
throw new InvalidRuleException(get_class());
}
}
$this->rules = array();
foreach ($rules as $rule) {
$this->addRule($rule);
}
$this->rules = $rules;
return $this;
}
@@ -236,7 +239,7 @@ abstract class CouponAbstract implements CouponInterface
$isMatching = true;
/** @var CouponRuleInterface $rule */
foreach ($this->rules as $rule) {
foreach ($this->rules->getRules() as $rule) {
if (!$rule->isMatching()) {
$isMatching = false;
}
@@ -245,5 +248,65 @@ abstract class CouponAbstract implements CouponInterface
return $isMatching;
}
/**
* Return Coupon expiration date
*
* @return \DateTime
*/
public function getExpirationDate()
{
return clone $this->expirationDate;
}
/**
* Check if the Coupon can be used against a
* product already with a special offer price
*
* @return boolean
*/
public function isAvailableOnSpecialOffers()
{
return $this->isAvailableOnSpecialOffers;
}
/**
* Check if Coupon has been disabled by admin
*
* @return boolean
*/
public function isEnabled()
{
return $this->isEnabled;
}
/**
* Return how many time the Coupon can be used again
* Ex : -1 unlimited
*
* @return int
*/
public function getMaxUsage()
{
return $this->maxUsage;
}
/**
* Check if the Coupon is already Expired
*
* @return bool
*/
public function isExpired()
{
$ret = true;
if ($this->expirationDate < new \DateTime()) {
$ret = false;
}
return $ret;
}
}

View File

@@ -23,6 +23,8 @@
namespace Thelia\Coupon\Type;
use Thelia\Coupon\CouponRuleCollection;
/**
* Created by JetBrains PhpStorm.
* Date: 8/19/13
@@ -114,10 +116,48 @@ interface CouponInterface
* Replace the existing Rules by those given in parameter
* If one Rule is badly implemented, no Rule will be added
*
* @param array $rules CouponRuleInterface to add
* @param CouponRuleCollection $rules CouponRuleInterface to add
*
* @return $this
* @throws \Thelia\Exception\InvalidRuleException
*/
public function setRules(array $rules);
public function setRules(CouponRuleCollection $rules);
/**
* Return Coupon expiration date
*
* @return \DateTime
*/
public function getExpirationDate();
/**
* Check if the Coupon can be used against a
* product already with a special offer price
*
* @return boolean
*/
public function isAvailableOnSpecialOffers();
/**
* Check if Coupon has been disabled by admin
*
* @return boolean
*/
public function isEnabled();
/**
* Return how many time the Coupon can be used again
* Ex : -1 unlimited
*
* @return int
*/
public function getMaxUsage();
/**
* Check if the Coupon is already Expired
*
* @return bool
*/
public function isExpired();
}

View File

@@ -41,15 +41,20 @@ class RemoveXAmount extends CouponAbstract
/**
* Constructor
*
* @param string $code Coupon code (ex: XMAS)
* @param string $title Coupon title (ex: Coupon for XMAS)
* @param string $shortDescription Coupon short description
* @param string $description Coupon description
* @param float $amount Coupon amount to deduce
* @param bool $isCumulative if Coupon is cumulative
* @param bool $isRemovingPostage if Coupon is removing postage
* @param string $code Coupon code (ex: XMAS)
* @param string $title Coupon title (ex: Coupon for XMAS)
* @param string $shortDescription Coupon short description
* @param string $description Coupon description
* @param float $amount Coupon amount to deduce
* @param bool $isCumulative If Coupon is cumulative
* @param bool $isRemovingPostage If Coupon is removing postage
* @param bool $isAvailableOnSpecialOffers If available on Product already
* on special offer price
* @param bool $isEnabled False if Coupon is disabled by admin
* @param int $maxUsage How many usage left
* @param \Datetime $expirationDate When the Code is expiring
*/
function __construct($code, $title, $shortDescription, $description, $amount, $isCumulative, $isRemovingPostage)
function __construct($code, $title, $shortDescription, $description, $amount, $isCumulative, $isRemovingPostage, $isAvailableOnSpecialOffers, $isEnabled, $maxUsage, \DateTime $expirationDate)
{
$this->code = $code;
$this->title = $title;
@@ -60,6 +65,11 @@ class RemoveXAmount extends CouponAbstract
$this->isRemovingPostage = $isRemovingPostage;
$this->amount = $amount;
$this->isAvailableOnSpecialOffers = $isAvailableOnSpecialOffers;
$this->isEnabled = $isEnabled;
$this->maxUsage = $maxUsage;
$this->expirationDate = $expirationDate;
}
}