- * $query->filterByAmount(1234); // WHERE amount = 1234
- * $query->filterByAmount(array(12, 34)); // WHERE amount IN (12, 34)
- * $query->filterByAmount(array('min' => 12)); // WHERE amount > 12
+ * $query->filterBySerializedEffects('fooValue'); // WHERE serialized_effects = 'fooValue'
+ * $query->filterBySerializedEffects('%fooValue%'); // WHERE serialized_effects LIKE '%fooValue%'
*
*
- * @param mixed $amount The value to use as filter.
- * Use scalar values for equality.
- * Use array values for in_array() equivalent.
- * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $serializedEffects The value to use as filter.
+ * Accepts wildcards (* and % trigger a LIKE)
* @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
*
* @return ChildCouponQuery The current query, for fluid interface
*/
- public function filterByAmount($amount = null, $comparison = null)
+ public function filterBySerializedEffects($serializedEffects = null, $comparison = null)
{
- if (is_array($amount)) {
- $useMinMax = false;
- if (isset($amount['min'])) {
- $this->addUsingAlias(CouponTableMap::AMOUNT, $amount['min'], Criteria::GREATER_EQUAL);
- $useMinMax = true;
- }
- if (isset($amount['max'])) {
- $this->addUsingAlias(CouponTableMap::AMOUNT, $amount['max'], Criteria::LESS_EQUAL);
- $useMinMax = true;
- }
- if ($useMinMax) {
- return $this;
- }
- if (null === $comparison) {
+ if (null === $comparison) {
+ if (is_array($serializedEffects)) {
$comparison = Criteria::IN;
+ } elseif (preg_match('/[\%\*]/', $serializedEffects)) {
+ $serializedEffects = str_replace('*', '%', $serializedEffects);
+ $comparison = Criteria::LIKE;
}
}
- return $this->addUsingAlias(CouponTableMap::AMOUNT, $amount, $comparison);
+ return $this->addUsingAlias(CouponTableMap::SERIALIZED_EFFECTS, $serializedEffects, $comparison);
}
/**
diff --git a/core/lib/Thelia/Model/Base/CouponVersion.php b/core/lib/Thelia/Model/Base/CouponVersion.php
index 67c077cfa..fa615af46 100644
--- a/core/lib/Thelia/Model/Base/CouponVersion.php
+++ b/core/lib/Thelia/Model/Base/CouponVersion.php
@@ -74,10 +74,10 @@ abstract class CouponVersion implements ActiveRecordInterface
protected $type;
/**
- * The value for the amount field.
- * @var double
+ * The value for the serialized_effects field.
+ * @var string
*/
- protected $amount;
+ protected $serialized_effects;
/**
* The value for the is_enabled field.
@@ -464,14 +464,14 @@ abstract class CouponVersion implements ActiveRecordInterface
}
/**
- * Get the [amount] column value.
+ * Get the [serialized_effects] column value.
*
- * @return double
+ * @return string
*/
- public function getAmount()
+ public function getSerializedEffects()
{
- return $this->amount;
+ return $this->serialized_effects;
}
/**
@@ -690,25 +690,25 @@ abstract class CouponVersion implements ActiveRecordInterface
} // setType()
/**
- * Set the value of [amount] column.
+ * Set the value of [serialized_effects] column.
*
- * @param double $v new value
+ * @param string $v new value
* @return \Thelia\Model\CouponVersion The current object (for fluent API support)
*/
- public function setAmount($v)
+ public function setSerializedEffects($v)
{
if ($v !== null) {
- $v = (double) $v;
+ $v = (string) $v;
}
- if ($this->amount !== $v) {
- $this->amount = $v;
- $this->modifiedColumns[] = CouponVersionTableMap::AMOUNT;
+ if ($this->serialized_effects !== $v) {
+ $this->serialized_effects = $v;
+ $this->modifiedColumns[] = CouponVersionTableMap::SERIALIZED_EFFECTS;
}
return $this;
- } // setAmount()
+ } // setSerializedEffects()
/**
* Sets the value of the [is_enabled] column.
@@ -1031,8 +1031,8 @@ abstract class CouponVersion implements ActiveRecordInterface
$col = $row[TableMap::TYPE_NUM == $indexType ? 2 + $startcol : CouponVersionTableMap::translateFieldName('Type', TableMap::TYPE_PHPNAME, $indexType)];
$this->type = (null !== $col) ? (string) $col : null;
- $col = $row[TableMap::TYPE_NUM == $indexType ? 3 + $startcol : CouponVersionTableMap::translateFieldName('Amount', TableMap::TYPE_PHPNAME, $indexType)];
- $this->amount = (null !== $col) ? (double) $col : null;
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 3 + $startcol : CouponVersionTableMap::translateFieldName('SerializedEffects', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->serialized_effects = (null !== $col) ? (string) $col : null;
$col = $row[TableMap::TYPE_NUM == $indexType ? 4 + $startcol : CouponVersionTableMap::translateFieldName('IsEnabled', TableMap::TYPE_PHPNAME, $indexType)];
$this->is_enabled = (null !== $col) ? (boolean) $col : null;
@@ -1313,8 +1313,8 @@ abstract class CouponVersion implements ActiveRecordInterface
if ($this->isColumnModified(CouponVersionTableMap::TYPE)) {
$modifiedColumns[':p' . $index++] = 'TYPE';
}
- if ($this->isColumnModified(CouponVersionTableMap::AMOUNT)) {
- $modifiedColumns[':p' . $index++] = 'AMOUNT';
+ if ($this->isColumnModified(CouponVersionTableMap::SERIALIZED_EFFECTS)) {
+ $modifiedColumns[':p' . $index++] = 'SERIALIZED_EFFECTS';
}
if ($this->isColumnModified(CouponVersionTableMap::IS_ENABLED)) {
$modifiedColumns[':p' . $index++] = 'IS_ENABLED';
@@ -1369,8 +1369,8 @@ abstract class CouponVersion implements ActiveRecordInterface
case 'TYPE':
$stmt->bindValue($identifier, $this->type, PDO::PARAM_STR);
break;
- case 'AMOUNT':
- $stmt->bindValue($identifier, $this->amount, PDO::PARAM_STR);
+ case 'SERIALIZED_EFFECTS':
+ $stmt->bindValue($identifier, $this->serialized_effects, PDO::PARAM_STR);
break;
case 'IS_ENABLED':
$stmt->bindValue($identifier, (int) $this->is_enabled, PDO::PARAM_INT);
@@ -1470,7 +1470,7 @@ abstract class CouponVersion implements ActiveRecordInterface
return $this->getType();
break;
case 3:
- return $this->getAmount();
+ return $this->getSerializedEffects();
break;
case 4:
return $this->getIsEnabled();
@@ -1537,7 +1537,7 @@ abstract class CouponVersion implements ActiveRecordInterface
$keys[0] => $this->getId(),
$keys[1] => $this->getCode(),
$keys[2] => $this->getType(),
- $keys[3] => $this->getAmount(),
+ $keys[3] => $this->getSerializedEffects(),
$keys[4] => $this->getIsEnabled(),
$keys[5] => $this->getExpirationDate(),
$keys[6] => $this->getMaxUsage(),
@@ -1603,7 +1603,7 @@ abstract class CouponVersion implements ActiveRecordInterface
$this->setType($value);
break;
case 3:
- $this->setAmount($value);
+ $this->setSerializedEffects($value);
break;
case 4:
$this->setIsEnabled($value);
@@ -1665,7 +1665,7 @@ abstract class CouponVersion implements ActiveRecordInterface
if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]);
if (array_key_exists($keys[1], $arr)) $this->setCode($arr[$keys[1]]);
if (array_key_exists($keys[2], $arr)) $this->setType($arr[$keys[2]]);
- if (array_key_exists($keys[3], $arr)) $this->setAmount($arr[$keys[3]]);
+ if (array_key_exists($keys[3], $arr)) $this->setSerializedEffects($arr[$keys[3]]);
if (array_key_exists($keys[4], $arr)) $this->setIsEnabled($arr[$keys[4]]);
if (array_key_exists($keys[5], $arr)) $this->setExpirationDate($arr[$keys[5]]);
if (array_key_exists($keys[6], $arr)) $this->setMaxUsage($arr[$keys[6]]);
@@ -1691,7 +1691,7 @@ abstract class CouponVersion implements ActiveRecordInterface
if ($this->isColumnModified(CouponVersionTableMap::ID)) $criteria->add(CouponVersionTableMap::ID, $this->id);
if ($this->isColumnModified(CouponVersionTableMap::CODE)) $criteria->add(CouponVersionTableMap::CODE, $this->code);
if ($this->isColumnModified(CouponVersionTableMap::TYPE)) $criteria->add(CouponVersionTableMap::TYPE, $this->type);
- if ($this->isColumnModified(CouponVersionTableMap::AMOUNT)) $criteria->add(CouponVersionTableMap::AMOUNT, $this->amount);
+ if ($this->isColumnModified(CouponVersionTableMap::SERIALIZED_EFFECTS)) $criteria->add(CouponVersionTableMap::SERIALIZED_EFFECTS, $this->serialized_effects);
if ($this->isColumnModified(CouponVersionTableMap::IS_ENABLED)) $criteria->add(CouponVersionTableMap::IS_ENABLED, $this->is_enabled);
if ($this->isColumnModified(CouponVersionTableMap::EXPIRATION_DATE)) $criteria->add(CouponVersionTableMap::EXPIRATION_DATE, $this->expiration_date);
if ($this->isColumnModified(CouponVersionTableMap::MAX_USAGE)) $criteria->add(CouponVersionTableMap::MAX_USAGE, $this->max_usage);
@@ -1776,7 +1776,7 @@ abstract class CouponVersion implements ActiveRecordInterface
$copyObj->setId($this->getId());
$copyObj->setCode($this->getCode());
$copyObj->setType($this->getType());
- $copyObj->setAmount($this->getAmount());
+ $copyObj->setSerializedEffects($this->getSerializedEffects());
$copyObj->setIsEnabled($this->getIsEnabled());
$copyObj->setExpirationDate($this->getExpirationDate());
$copyObj->setMaxUsage($this->getMaxUsage());
@@ -1874,7 +1874,7 @@ abstract class CouponVersion implements ActiveRecordInterface
$this->id = null;
$this->code = null;
$this->type = null;
- $this->amount = null;
+ $this->serialized_effects = null;
$this->is_enabled = null;
$this->expiration_date = null;
$this->max_usage = null;
diff --git a/core/lib/Thelia/Model/Base/CouponVersionQuery.php b/core/lib/Thelia/Model/Base/CouponVersionQuery.php
index eebd85dd9..1cfdb8fb8 100644
--- a/core/lib/Thelia/Model/Base/CouponVersionQuery.php
+++ b/core/lib/Thelia/Model/Base/CouponVersionQuery.php
@@ -24,7 +24,7 @@ use Thelia\Model\Map\CouponVersionTableMap;
* @method ChildCouponVersionQuery orderById($order = Criteria::ASC) Order by the id column
* @method ChildCouponVersionQuery orderByCode($order = Criteria::ASC) Order by the code column
* @method ChildCouponVersionQuery orderByType($order = Criteria::ASC) Order by the type column
- * @method ChildCouponVersionQuery orderByAmount($order = Criteria::ASC) Order by the amount column
+ * @method ChildCouponVersionQuery orderBySerializedEffects($order = Criteria::ASC) Order by the serialized_effects column
* @method ChildCouponVersionQuery orderByIsEnabled($order = Criteria::ASC) Order by the is_enabled column
* @method ChildCouponVersionQuery orderByExpirationDate($order = Criteria::ASC) Order by the expiration_date column
* @method ChildCouponVersionQuery orderByMaxUsage($order = Criteria::ASC) Order by the max_usage column
@@ -40,7 +40,7 @@ use Thelia\Model\Map\CouponVersionTableMap;
* @method ChildCouponVersionQuery groupById() Group by the id column
* @method ChildCouponVersionQuery groupByCode() Group by the code column
* @method ChildCouponVersionQuery groupByType() Group by the type column
- * @method ChildCouponVersionQuery groupByAmount() Group by the amount column
+ * @method ChildCouponVersionQuery groupBySerializedEffects() Group by the serialized_effects column
* @method ChildCouponVersionQuery groupByIsEnabled() Group by the is_enabled column
* @method ChildCouponVersionQuery groupByExpirationDate() Group by the expiration_date column
* @method ChildCouponVersionQuery groupByMaxUsage() Group by the max_usage column
@@ -67,7 +67,7 @@ use Thelia\Model\Map\CouponVersionTableMap;
* @method ChildCouponVersion findOneById(int $id) Return the first ChildCouponVersion filtered by the id column
* @method ChildCouponVersion findOneByCode(string $code) Return the first ChildCouponVersion filtered by the code column
* @method ChildCouponVersion findOneByType(string $type) Return the first ChildCouponVersion filtered by the type column
- * @method ChildCouponVersion findOneByAmount(double $amount) Return the first ChildCouponVersion filtered by the amount column
+ * @method ChildCouponVersion findOneBySerializedEffects(string $serialized_effects) Return the first ChildCouponVersion filtered by the serialized_effects column
* @method ChildCouponVersion findOneByIsEnabled(boolean $is_enabled) Return the first ChildCouponVersion filtered by the is_enabled column
* @method ChildCouponVersion findOneByExpirationDate(string $expiration_date) Return the first ChildCouponVersion filtered by the expiration_date column
* @method ChildCouponVersion findOneByMaxUsage(int $max_usage) Return the first ChildCouponVersion filtered by the max_usage column
@@ -83,7 +83,7 @@ use Thelia\Model\Map\CouponVersionTableMap;
* @method array findById(int $id) Return ChildCouponVersion objects filtered by the id column
* @method array findByCode(string $code) Return ChildCouponVersion objects filtered by the code column
* @method array findByType(string $type) Return ChildCouponVersion objects filtered by the type column
- * @method array findByAmount(double $amount) Return ChildCouponVersion objects filtered by the amount column
+ * @method array findBySerializedEffects(string $serialized_effects) Return ChildCouponVersion objects filtered by the serialized_effects column
* @method array findByIsEnabled(boolean $is_enabled) Return ChildCouponVersion objects filtered by the is_enabled column
* @method array findByExpirationDate(string $expiration_date) Return ChildCouponVersion objects filtered by the expiration_date column
* @method array findByMaxUsage(int $max_usage) Return ChildCouponVersion objects filtered by the max_usage column
@@ -183,7 +183,7 @@ abstract class CouponVersionQuery extends ModelCriteria
*/
protected function findPkSimple($key, $con)
{
- $sql = 'SELECT ID, CODE, TYPE, AMOUNT, IS_ENABLED, EXPIRATION_DATE, MAX_USAGE, IS_CUMULATIVE, IS_REMOVING_POSTAGE, IS_AVAILABLE_ON_SPECIAL_OFFERS, IS_USED, SERIALIZED_CONDITIONS, CREATED_AT, UPDATED_AT, VERSION FROM coupon_version WHERE ID = :p0 AND VERSION = :p1';
+ $sql = 'SELECT ID, CODE, TYPE, SERIALIZED_EFFECTS, IS_ENABLED, EXPIRATION_DATE, MAX_USAGE, IS_CUMULATIVE, IS_REMOVING_POSTAGE, IS_AVAILABLE_ON_SPECIAL_OFFERS, IS_USED, SERIALIZED_CONDITIONS, CREATED_AT, UPDATED_AT, VERSION FROM coupon_version WHERE ID = :p0 AND VERSION = :p1';
try {
$stmt = $con->prepare($sql);
$stmt->bindValue(':p0', $key[0], PDO::PARAM_INT);
@@ -386,44 +386,32 @@ abstract class CouponVersionQuery extends ModelCriteria
}
/**
- * Filter the query on the amount column
+ * Filter the query on the serialized_effects column
*
* Example usage:
*
- * $query->filterByAmount(1234); // WHERE amount = 1234
- * $query->filterByAmount(array(12, 34)); // WHERE amount IN (12, 34)
- * $query->filterByAmount(array('min' => 12)); // WHERE amount > 12
+ * $query->filterBySerializedEffects('fooValue'); // WHERE serialized_effects = 'fooValue'
+ * $query->filterBySerializedEffects('%fooValue%'); // WHERE serialized_effects LIKE '%fooValue%'
*
*
- * @param mixed $amount The value to use as filter.
- * Use scalar values for equality.
- * Use array values for in_array() equivalent.
- * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $serializedEffects The value to use as filter.
+ * Accepts wildcards (* and % trigger a LIKE)
* @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
*
* @return ChildCouponVersionQuery The current query, for fluid interface
*/
- public function filterByAmount($amount = null, $comparison = null)
+ public function filterBySerializedEffects($serializedEffects = null, $comparison = null)
{
- if (is_array($amount)) {
- $useMinMax = false;
- if (isset($amount['min'])) {
- $this->addUsingAlias(CouponVersionTableMap::AMOUNT, $amount['min'], Criteria::GREATER_EQUAL);
- $useMinMax = true;
- }
- if (isset($amount['max'])) {
- $this->addUsingAlias(CouponVersionTableMap::AMOUNT, $amount['max'], Criteria::LESS_EQUAL);
- $useMinMax = true;
- }
- if ($useMinMax) {
- return $this;
- }
- if (null === $comparison) {
+ if (null === $comparison) {
+ if (is_array($serializedEffects)) {
$comparison = Criteria::IN;
+ } elseif (preg_match('/[\%\*]/', $serializedEffects)) {
+ $serializedEffects = str_replace('*', '%', $serializedEffects);
+ $comparison = Criteria::LIKE;
}
}
- return $this->addUsingAlias(CouponVersionTableMap::AMOUNT, $amount, $comparison);
+ return $this->addUsingAlias(CouponVersionTableMap::SERIALIZED_EFFECTS, $serializedEffects, $comparison);
}
/**
diff --git a/core/lib/Thelia/Model/Base/OrderCouponQuery.php b/core/lib/Thelia/Model/Base/OrderCouponQuery.php
old mode 100644
new mode 100755
diff --git a/core/lib/Thelia/Model/Coupon.php b/core/lib/Thelia/Model/Coupon.php
index c4f74569d..55fa6445d 100755
--- a/core/lib/Thelia/Model/Coupon.php
+++ b/core/lib/Thelia/Model/Coupon.php
@@ -27,13 +27,10 @@ use Propel\Runtime\Propel;
use Thelia\Constraint\Rule\CouponRuleInterface;
use Thelia\Coupon\ConditionCollection;
use Thelia\Model\Base\Coupon as BaseCoupon;
+use Thelia\Model\Exception\InvalidArgumentException;
use Thelia\Model\Map\CouponTableMap;
/**
- * Created by JetBrains PhpStorm.
- * Date: 8/19/13
- * Time: 3:24 PM
- *
* Used to provide an effect (mostly a discount)
* at the end of the Customer checkout tunnel
* It will be usable for a Customer only if it matches the Coupon criteria (Rules)
@@ -53,7 +50,7 @@ class Coupon extends BaseCoupon
*
* @param string $code Coupon Code
* @param string $title Coupon title
- * @param float $amount Amount removed from the Total Checkout
+ * @param array $effects Ready to be serialized in JSON effect params
* @param string $type Coupon type
* @param bool $isRemovingPostage Is removing Postage
* @param string $shortDescription Coupon short description
@@ -68,20 +65,20 @@ class Coupon extends BaseCoupon
*
* @throws \Exception
*/
- function createOrUpdate($code, $title, $amount, $type, $isRemovingPostage, $shortDescription, $description, $isEnabled, $expirationDate, $isAvailableOnSpecialOffers, $isCumulative, $maxUsage, $defaultSerializedRule, $locale = null)
+ function createOrUpdate($code, $title, array $effects, $type, $isRemovingPostage, $shortDescription, $description, $isEnabled, $expirationDate, $isAvailableOnSpecialOffers, $isCumulative, $maxUsage, $defaultSerializedRule, $locale = null)
{
$this->setCode($code)
- ->setTitle($title)
- ->setShortDescription($shortDescription)
- ->setDescription($description)
->setType($type)
- ->setAmount($amount)
+ ->setEffects($effects)
->setIsRemovingPostage($isRemovingPostage)
->setIsEnabled($isEnabled)
->setExpirationDate($expirationDate)
->setIsAvailableOnSpecialOffers($isAvailableOnSpecialOffers)
->setIsCumulative($isCumulative)
->setMaxUsage($maxUsage);
+ $this->setTitle($title)
+ ->setShortDescription($shortDescription)
+ ->setDescription($description);
// If no rule given, set default rule
if (null === $this->getSerializedConditions()) {
@@ -132,4 +129,98 @@ class Coupon extends BaseCoupon
throw $e;
}
}
+
+ /**
+ * Set Coupon amount
+ *
+ * @param float $amount Amount deduced from the Cart
+ *
+ * @return $this
+ */
+ public function setAmount($amount)
+ {
+ $effects = $this->unserializeEffects($this->getSerializedEffects());
+ $effects['amount'] = floatval($amount);
+ $this->setEffects($effects);
+
+ return $this;
+ }
+
+ /**
+ * Get the amount removed from the coupon to the cart
+ *
+ * @return float
+ */
+ public function getAmount()
+ {
+ $amount = $this->getEffects()['amount'];
+
+ return floatval($amount);
+ }
+
+ /**
+ * Get the Coupon effects
+ *
+ * @return array
+ * @throws Exception\InvalidArgumentException
+ */
+ public function getEffects()
+ {
+ $effects = $this->unserializeEffects($this->getSerializedEffects());
+
+ if (null === $effects['amount']) {
+ throw new InvalidArgumentException('Missing key \'amount\' in Coupon effect coming from database');
+ }
+
+ return $effects;
+ }
+
+ /**
+ * Get the Coupon effects
+ *
+ * @param array $effects Effect ready to be serialized
+ * Needs at least the key 'amount'
+ * with the amount removed from the cart
+ *
+ * @throws Exception\InvalidArgumentException
+ * @return $this
+ */
+ public function setEffects(array $effects)
+ {
+ if (null === $effects['amount']) {
+ throw new InvalidArgumentException('Missing key \'amount\' in Coupon effect ready to be serialized array');
+ }
+
+ $this->setSerializedEffects($this->serializeEffects($effects));
+
+ return $this;
+ }
+
+ /**
+ * Return unserialized effects
+ *
+ * @param string $serializedEffects Serialized effect string to unserialize
+ *
+ * @return array
+ */
+ public function unserializeEffects($serializedEffects)
+ {
+ $effects = json_decode($serializedEffects, true);
+
+ return $effects;
+ }
+
+ /**
+ * Return serialized effects
+ *
+ * @param array $unserializedEffects Unserialized array string to serialize
+ *
+ * @return string
+ */
+ public function serializeEffects(array $unserializedEffects)
+ {
+ $effects = json_encode($unserializedEffects);
+
+ return $effects;
+ }
}
diff --git a/core/lib/Thelia/Model/Map/CouponTableMap.php b/core/lib/Thelia/Model/Map/CouponTableMap.php
index 70d689a2a..830102ad3 100644
--- a/core/lib/Thelia/Model/Map/CouponTableMap.php
+++ b/core/lib/Thelia/Model/Map/CouponTableMap.php
@@ -85,9 +85,9 @@ class CouponTableMap extends TableMap
const TYPE = 'coupon.TYPE';
/**
- * the column name for the AMOUNT field
+ * the column name for the SERIALIZED_EFFECTS field
*/
- const AMOUNT = 'coupon.AMOUNT';
+ const SERIALIZED_EFFECTS = 'coupon.SERIALIZED_EFFECTS';
/**
* the column name for the IS_ENABLED field
@@ -165,11 +165,11 @@ class CouponTableMap extends TableMap
* e.g. self::$fieldNames[self::TYPE_PHPNAME][0] = 'Id'
*/
protected static $fieldNames = array (
- self::TYPE_PHPNAME => array('Id', 'Code', 'Type', 'Amount', 'IsEnabled', 'ExpirationDate', 'MaxUsage', 'IsCumulative', 'IsRemovingPostage', 'IsAvailableOnSpecialOffers', 'IsUsed', 'SerializedConditions', 'CreatedAt', 'UpdatedAt', 'Version', ),
- self::TYPE_STUDLYPHPNAME => array('id', 'code', 'type', 'amount', 'isEnabled', 'expirationDate', 'maxUsage', 'isCumulative', 'isRemovingPostage', 'isAvailableOnSpecialOffers', 'isUsed', 'serializedConditions', 'createdAt', 'updatedAt', 'version', ),
- self::TYPE_COLNAME => array(CouponTableMap::ID, CouponTableMap::CODE, CouponTableMap::TYPE, CouponTableMap::AMOUNT, CouponTableMap::IS_ENABLED, CouponTableMap::EXPIRATION_DATE, CouponTableMap::MAX_USAGE, CouponTableMap::IS_CUMULATIVE, CouponTableMap::IS_REMOVING_POSTAGE, CouponTableMap::IS_AVAILABLE_ON_SPECIAL_OFFERS, CouponTableMap::IS_USED, CouponTableMap::SERIALIZED_CONDITIONS, CouponTableMap::CREATED_AT, CouponTableMap::UPDATED_AT, CouponTableMap::VERSION, ),
- self::TYPE_RAW_COLNAME => array('ID', 'CODE', 'TYPE', 'AMOUNT', 'IS_ENABLED', 'EXPIRATION_DATE', 'MAX_USAGE', 'IS_CUMULATIVE', 'IS_REMOVING_POSTAGE', 'IS_AVAILABLE_ON_SPECIAL_OFFERS', 'IS_USED', 'SERIALIZED_CONDITIONS', 'CREATED_AT', 'UPDATED_AT', 'VERSION', ),
- self::TYPE_FIELDNAME => array('id', 'code', 'type', 'amount', 'is_enabled', 'expiration_date', 'max_usage', 'is_cumulative', 'is_removing_postage', 'is_available_on_special_offers', 'is_used', 'serialized_conditions', 'created_at', 'updated_at', 'version', ),
+ self::TYPE_PHPNAME => array('Id', 'Code', 'Type', 'SerializedEffects', 'IsEnabled', 'ExpirationDate', 'MaxUsage', 'IsCumulative', 'IsRemovingPostage', 'IsAvailableOnSpecialOffers', 'IsUsed', 'SerializedConditions', 'CreatedAt', 'UpdatedAt', 'Version', ),
+ self::TYPE_STUDLYPHPNAME => array('id', 'code', 'type', 'serializedEffects', 'isEnabled', 'expirationDate', 'maxUsage', 'isCumulative', 'isRemovingPostage', 'isAvailableOnSpecialOffers', 'isUsed', 'serializedConditions', 'createdAt', 'updatedAt', 'version', ),
+ self::TYPE_COLNAME => array(CouponTableMap::ID, CouponTableMap::CODE, CouponTableMap::TYPE, CouponTableMap::SERIALIZED_EFFECTS, CouponTableMap::IS_ENABLED, CouponTableMap::EXPIRATION_DATE, CouponTableMap::MAX_USAGE, CouponTableMap::IS_CUMULATIVE, CouponTableMap::IS_REMOVING_POSTAGE, CouponTableMap::IS_AVAILABLE_ON_SPECIAL_OFFERS, CouponTableMap::IS_USED, CouponTableMap::SERIALIZED_CONDITIONS, CouponTableMap::CREATED_AT, CouponTableMap::UPDATED_AT, CouponTableMap::VERSION, ),
+ self::TYPE_RAW_COLNAME => array('ID', 'CODE', 'TYPE', 'SERIALIZED_EFFECTS', 'IS_ENABLED', 'EXPIRATION_DATE', 'MAX_USAGE', 'IS_CUMULATIVE', 'IS_REMOVING_POSTAGE', 'IS_AVAILABLE_ON_SPECIAL_OFFERS', 'IS_USED', 'SERIALIZED_CONDITIONS', 'CREATED_AT', 'UPDATED_AT', 'VERSION', ),
+ self::TYPE_FIELDNAME => array('id', 'code', 'type', 'serialized_effects', 'is_enabled', 'expiration_date', 'max_usage', 'is_cumulative', 'is_removing_postage', 'is_available_on_special_offers', 'is_used', 'serialized_conditions', 'created_at', 'updated_at', 'version', ),
self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, )
);
@@ -180,11 +180,11 @@ class CouponTableMap extends TableMap
* e.g. self::$fieldKeys[self::TYPE_PHPNAME]['Id'] = 0
*/
protected static $fieldKeys = array (
- self::TYPE_PHPNAME => array('Id' => 0, 'Code' => 1, 'Type' => 2, 'Amount' => 3, 'IsEnabled' => 4, 'ExpirationDate' => 5, 'MaxUsage' => 6, 'IsCumulative' => 7, 'IsRemovingPostage' => 8, 'IsAvailableOnSpecialOffers' => 9, 'IsUsed' => 10, 'SerializedConditions' => 11, 'CreatedAt' => 12, 'UpdatedAt' => 13, 'Version' => 14, ),
- self::TYPE_STUDLYPHPNAME => array('id' => 0, 'code' => 1, 'type' => 2, 'amount' => 3, 'isEnabled' => 4, 'expirationDate' => 5, 'maxUsage' => 6, 'isCumulative' => 7, 'isRemovingPostage' => 8, 'isAvailableOnSpecialOffers' => 9, 'isUsed' => 10, 'serializedConditions' => 11, 'createdAt' => 12, 'updatedAt' => 13, 'version' => 14, ),
- self::TYPE_COLNAME => array(CouponTableMap::ID => 0, CouponTableMap::CODE => 1, CouponTableMap::TYPE => 2, CouponTableMap::AMOUNT => 3, CouponTableMap::IS_ENABLED => 4, CouponTableMap::EXPIRATION_DATE => 5, CouponTableMap::MAX_USAGE => 6, CouponTableMap::IS_CUMULATIVE => 7, CouponTableMap::IS_REMOVING_POSTAGE => 8, CouponTableMap::IS_AVAILABLE_ON_SPECIAL_OFFERS => 9, CouponTableMap::IS_USED => 10, CouponTableMap::SERIALIZED_CONDITIONS => 11, CouponTableMap::CREATED_AT => 12, CouponTableMap::UPDATED_AT => 13, CouponTableMap::VERSION => 14, ),
- self::TYPE_RAW_COLNAME => array('ID' => 0, 'CODE' => 1, 'TYPE' => 2, 'AMOUNT' => 3, 'IS_ENABLED' => 4, 'EXPIRATION_DATE' => 5, 'MAX_USAGE' => 6, 'IS_CUMULATIVE' => 7, 'IS_REMOVING_POSTAGE' => 8, 'IS_AVAILABLE_ON_SPECIAL_OFFERS' => 9, 'IS_USED' => 10, 'SERIALIZED_CONDITIONS' => 11, 'CREATED_AT' => 12, 'UPDATED_AT' => 13, 'VERSION' => 14, ),
- self::TYPE_FIELDNAME => array('id' => 0, 'code' => 1, 'type' => 2, 'amount' => 3, 'is_enabled' => 4, 'expiration_date' => 5, 'max_usage' => 6, 'is_cumulative' => 7, 'is_removing_postage' => 8, 'is_available_on_special_offers' => 9, 'is_used' => 10, 'serialized_conditions' => 11, 'created_at' => 12, 'updated_at' => 13, 'version' => 14, ),
+ self::TYPE_PHPNAME => array('Id' => 0, 'Code' => 1, 'Type' => 2, 'SerializedEffects' => 3, 'IsEnabled' => 4, 'ExpirationDate' => 5, 'MaxUsage' => 6, 'IsCumulative' => 7, 'IsRemovingPostage' => 8, 'IsAvailableOnSpecialOffers' => 9, 'IsUsed' => 10, 'SerializedConditions' => 11, 'CreatedAt' => 12, 'UpdatedAt' => 13, 'Version' => 14, ),
+ self::TYPE_STUDLYPHPNAME => array('id' => 0, 'code' => 1, 'type' => 2, 'serializedEffects' => 3, 'isEnabled' => 4, 'expirationDate' => 5, 'maxUsage' => 6, 'isCumulative' => 7, 'isRemovingPostage' => 8, 'isAvailableOnSpecialOffers' => 9, 'isUsed' => 10, 'serializedConditions' => 11, 'createdAt' => 12, 'updatedAt' => 13, 'version' => 14, ),
+ self::TYPE_COLNAME => array(CouponTableMap::ID => 0, CouponTableMap::CODE => 1, CouponTableMap::TYPE => 2, CouponTableMap::SERIALIZED_EFFECTS => 3, CouponTableMap::IS_ENABLED => 4, CouponTableMap::EXPIRATION_DATE => 5, CouponTableMap::MAX_USAGE => 6, CouponTableMap::IS_CUMULATIVE => 7, CouponTableMap::IS_REMOVING_POSTAGE => 8, CouponTableMap::IS_AVAILABLE_ON_SPECIAL_OFFERS => 9, CouponTableMap::IS_USED => 10, CouponTableMap::SERIALIZED_CONDITIONS => 11, CouponTableMap::CREATED_AT => 12, CouponTableMap::UPDATED_AT => 13, CouponTableMap::VERSION => 14, ),
+ self::TYPE_RAW_COLNAME => array('ID' => 0, 'CODE' => 1, 'TYPE' => 2, 'SERIALIZED_EFFECTS' => 3, 'IS_ENABLED' => 4, 'EXPIRATION_DATE' => 5, 'MAX_USAGE' => 6, 'IS_CUMULATIVE' => 7, 'IS_REMOVING_POSTAGE' => 8, 'IS_AVAILABLE_ON_SPECIAL_OFFERS' => 9, 'IS_USED' => 10, 'SERIALIZED_CONDITIONS' => 11, 'CREATED_AT' => 12, 'UPDATED_AT' => 13, 'VERSION' => 14, ),
+ self::TYPE_FIELDNAME => array('id' => 0, 'code' => 1, 'type' => 2, 'serialized_effects' => 3, 'is_enabled' => 4, 'expiration_date' => 5, 'max_usage' => 6, 'is_cumulative' => 7, 'is_removing_postage' => 8, 'is_available_on_special_offers' => 9, 'is_used' => 10, 'serialized_conditions' => 11, 'created_at' => 12, 'updated_at' => 13, 'version' => 14, ),
self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, )
);
@@ -207,7 +207,7 @@ class CouponTableMap extends TableMap
$this->addPrimaryKey('ID', 'Id', 'INTEGER', true, null, null);
$this->addColumn('CODE', 'Code', 'VARCHAR', true, 45, null);
$this->addColumn('TYPE', 'Type', 'VARCHAR', true, 255, null);
- $this->addColumn('AMOUNT', 'Amount', 'FLOAT', true, null, null);
+ $this->addColumn('SERIALIZED_EFFECTS', 'SerializedEffects', 'LONGVARCHAR', true, null, null);
$this->addColumn('IS_ENABLED', 'IsEnabled', 'BOOLEAN', true, 1, null);
$this->addColumn('EXPIRATION_DATE', 'ExpirationDate', 'TIMESTAMP', true, null, null);
$this->addColumn('MAX_USAGE', 'MaxUsage', 'INTEGER', true, null, null);
@@ -396,7 +396,7 @@ class CouponTableMap extends TableMap
$criteria->addSelectColumn(CouponTableMap::ID);
$criteria->addSelectColumn(CouponTableMap::CODE);
$criteria->addSelectColumn(CouponTableMap::TYPE);
- $criteria->addSelectColumn(CouponTableMap::AMOUNT);
+ $criteria->addSelectColumn(CouponTableMap::SERIALIZED_EFFECTS);
$criteria->addSelectColumn(CouponTableMap::IS_ENABLED);
$criteria->addSelectColumn(CouponTableMap::EXPIRATION_DATE);
$criteria->addSelectColumn(CouponTableMap::MAX_USAGE);
@@ -412,7 +412,7 @@ class CouponTableMap extends TableMap
$criteria->addSelectColumn($alias . '.ID');
$criteria->addSelectColumn($alias . '.CODE');
$criteria->addSelectColumn($alias . '.TYPE');
- $criteria->addSelectColumn($alias . '.AMOUNT');
+ $criteria->addSelectColumn($alias . '.SERIALIZED_EFFECTS');
$criteria->addSelectColumn($alias . '.IS_ENABLED');
$criteria->addSelectColumn($alias . '.EXPIRATION_DATE');
$criteria->addSelectColumn($alias . '.MAX_USAGE');
diff --git a/core/lib/Thelia/Model/Map/CouponVersionTableMap.php b/core/lib/Thelia/Model/Map/CouponVersionTableMap.php
index 91e774912..8fbd7e68d 100644
--- a/core/lib/Thelia/Model/Map/CouponVersionTableMap.php
+++ b/core/lib/Thelia/Model/Map/CouponVersionTableMap.php
@@ -85,9 +85,9 @@ class CouponVersionTableMap extends TableMap
const TYPE = 'coupon_version.TYPE';
/**
- * the column name for the AMOUNT field
+ * the column name for the SERIALIZED_EFFECTS field
*/
- const AMOUNT = 'coupon_version.AMOUNT';
+ const SERIALIZED_EFFECTS = 'coupon_version.SERIALIZED_EFFECTS';
/**
* the column name for the IS_ENABLED field
@@ -156,11 +156,11 @@ class CouponVersionTableMap extends TableMap
* e.g. self::$fieldNames[self::TYPE_PHPNAME][0] = 'Id'
*/
protected static $fieldNames = array (
- self::TYPE_PHPNAME => array('Id', 'Code', 'Type', 'Amount', 'IsEnabled', 'ExpirationDate', 'MaxUsage', 'IsCumulative', 'IsRemovingPostage', 'IsAvailableOnSpecialOffers', 'IsUsed', 'SerializedConditions', 'CreatedAt', 'UpdatedAt', 'Version', ),
- self::TYPE_STUDLYPHPNAME => array('id', 'code', 'type', 'amount', 'isEnabled', 'expirationDate', 'maxUsage', 'isCumulative', 'isRemovingPostage', 'isAvailableOnSpecialOffers', 'isUsed', 'serializedConditions', 'createdAt', 'updatedAt', 'version', ),
- self::TYPE_COLNAME => array(CouponVersionTableMap::ID, CouponVersionTableMap::CODE, CouponVersionTableMap::TYPE, CouponVersionTableMap::AMOUNT, CouponVersionTableMap::IS_ENABLED, CouponVersionTableMap::EXPIRATION_DATE, CouponVersionTableMap::MAX_USAGE, CouponVersionTableMap::IS_CUMULATIVE, CouponVersionTableMap::IS_REMOVING_POSTAGE, CouponVersionTableMap::IS_AVAILABLE_ON_SPECIAL_OFFERS, CouponVersionTableMap::IS_USED, CouponVersionTableMap::SERIALIZED_CONDITIONS, CouponVersionTableMap::CREATED_AT, CouponVersionTableMap::UPDATED_AT, CouponVersionTableMap::VERSION, ),
- self::TYPE_RAW_COLNAME => array('ID', 'CODE', 'TYPE', 'AMOUNT', 'IS_ENABLED', 'EXPIRATION_DATE', 'MAX_USAGE', 'IS_CUMULATIVE', 'IS_REMOVING_POSTAGE', 'IS_AVAILABLE_ON_SPECIAL_OFFERS', 'IS_USED', 'SERIALIZED_CONDITIONS', 'CREATED_AT', 'UPDATED_AT', 'VERSION', ),
- self::TYPE_FIELDNAME => array('id', 'code', 'type', 'amount', 'is_enabled', 'expiration_date', 'max_usage', 'is_cumulative', 'is_removing_postage', 'is_available_on_special_offers', 'is_used', 'serialized_conditions', 'created_at', 'updated_at', 'version', ),
+ self::TYPE_PHPNAME => array('Id', 'Code', 'Type', 'SerializedEffects', 'IsEnabled', 'ExpirationDate', 'MaxUsage', 'IsCumulative', 'IsRemovingPostage', 'IsAvailableOnSpecialOffers', 'IsUsed', 'SerializedConditions', 'CreatedAt', 'UpdatedAt', 'Version', ),
+ self::TYPE_STUDLYPHPNAME => array('id', 'code', 'type', 'serializedEffects', 'isEnabled', 'expirationDate', 'maxUsage', 'isCumulative', 'isRemovingPostage', 'isAvailableOnSpecialOffers', 'isUsed', 'serializedConditions', 'createdAt', 'updatedAt', 'version', ),
+ self::TYPE_COLNAME => array(CouponVersionTableMap::ID, CouponVersionTableMap::CODE, CouponVersionTableMap::TYPE, CouponVersionTableMap::SERIALIZED_EFFECTS, CouponVersionTableMap::IS_ENABLED, CouponVersionTableMap::EXPIRATION_DATE, CouponVersionTableMap::MAX_USAGE, CouponVersionTableMap::IS_CUMULATIVE, CouponVersionTableMap::IS_REMOVING_POSTAGE, CouponVersionTableMap::IS_AVAILABLE_ON_SPECIAL_OFFERS, CouponVersionTableMap::IS_USED, CouponVersionTableMap::SERIALIZED_CONDITIONS, CouponVersionTableMap::CREATED_AT, CouponVersionTableMap::UPDATED_AT, CouponVersionTableMap::VERSION, ),
+ self::TYPE_RAW_COLNAME => array('ID', 'CODE', 'TYPE', 'SERIALIZED_EFFECTS', 'IS_ENABLED', 'EXPIRATION_DATE', 'MAX_USAGE', 'IS_CUMULATIVE', 'IS_REMOVING_POSTAGE', 'IS_AVAILABLE_ON_SPECIAL_OFFERS', 'IS_USED', 'SERIALIZED_CONDITIONS', 'CREATED_AT', 'UPDATED_AT', 'VERSION', ),
+ self::TYPE_FIELDNAME => array('id', 'code', 'type', 'serialized_effects', 'is_enabled', 'expiration_date', 'max_usage', 'is_cumulative', 'is_removing_postage', 'is_available_on_special_offers', 'is_used', 'serialized_conditions', 'created_at', 'updated_at', 'version', ),
self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, )
);
@@ -171,11 +171,11 @@ class CouponVersionTableMap extends TableMap
* e.g. self::$fieldKeys[self::TYPE_PHPNAME]['Id'] = 0
*/
protected static $fieldKeys = array (
- self::TYPE_PHPNAME => array('Id' => 0, 'Code' => 1, 'Type' => 2, 'Amount' => 3, 'IsEnabled' => 4, 'ExpirationDate' => 5, 'MaxUsage' => 6, 'IsCumulative' => 7, 'IsRemovingPostage' => 8, 'IsAvailableOnSpecialOffers' => 9, 'IsUsed' => 10, 'SerializedConditions' => 11, 'CreatedAt' => 12, 'UpdatedAt' => 13, 'Version' => 14, ),
- self::TYPE_STUDLYPHPNAME => array('id' => 0, 'code' => 1, 'type' => 2, 'amount' => 3, 'isEnabled' => 4, 'expirationDate' => 5, 'maxUsage' => 6, 'isCumulative' => 7, 'isRemovingPostage' => 8, 'isAvailableOnSpecialOffers' => 9, 'isUsed' => 10, 'serializedConditions' => 11, 'createdAt' => 12, 'updatedAt' => 13, 'version' => 14, ),
- self::TYPE_COLNAME => array(CouponVersionTableMap::ID => 0, CouponVersionTableMap::CODE => 1, CouponVersionTableMap::TYPE => 2, CouponVersionTableMap::AMOUNT => 3, CouponVersionTableMap::IS_ENABLED => 4, CouponVersionTableMap::EXPIRATION_DATE => 5, CouponVersionTableMap::MAX_USAGE => 6, CouponVersionTableMap::IS_CUMULATIVE => 7, CouponVersionTableMap::IS_REMOVING_POSTAGE => 8, CouponVersionTableMap::IS_AVAILABLE_ON_SPECIAL_OFFERS => 9, CouponVersionTableMap::IS_USED => 10, CouponVersionTableMap::SERIALIZED_CONDITIONS => 11, CouponVersionTableMap::CREATED_AT => 12, CouponVersionTableMap::UPDATED_AT => 13, CouponVersionTableMap::VERSION => 14, ),
- self::TYPE_RAW_COLNAME => array('ID' => 0, 'CODE' => 1, 'TYPE' => 2, 'AMOUNT' => 3, 'IS_ENABLED' => 4, 'EXPIRATION_DATE' => 5, 'MAX_USAGE' => 6, 'IS_CUMULATIVE' => 7, 'IS_REMOVING_POSTAGE' => 8, 'IS_AVAILABLE_ON_SPECIAL_OFFERS' => 9, 'IS_USED' => 10, 'SERIALIZED_CONDITIONS' => 11, 'CREATED_AT' => 12, 'UPDATED_AT' => 13, 'VERSION' => 14, ),
- self::TYPE_FIELDNAME => array('id' => 0, 'code' => 1, 'type' => 2, 'amount' => 3, 'is_enabled' => 4, 'expiration_date' => 5, 'max_usage' => 6, 'is_cumulative' => 7, 'is_removing_postage' => 8, 'is_available_on_special_offers' => 9, 'is_used' => 10, 'serialized_conditions' => 11, 'created_at' => 12, 'updated_at' => 13, 'version' => 14, ),
+ self::TYPE_PHPNAME => array('Id' => 0, 'Code' => 1, 'Type' => 2, 'SerializedEffects' => 3, 'IsEnabled' => 4, 'ExpirationDate' => 5, 'MaxUsage' => 6, 'IsCumulative' => 7, 'IsRemovingPostage' => 8, 'IsAvailableOnSpecialOffers' => 9, 'IsUsed' => 10, 'SerializedConditions' => 11, 'CreatedAt' => 12, 'UpdatedAt' => 13, 'Version' => 14, ),
+ self::TYPE_STUDLYPHPNAME => array('id' => 0, 'code' => 1, 'type' => 2, 'serializedEffects' => 3, 'isEnabled' => 4, 'expirationDate' => 5, 'maxUsage' => 6, 'isCumulative' => 7, 'isRemovingPostage' => 8, 'isAvailableOnSpecialOffers' => 9, 'isUsed' => 10, 'serializedConditions' => 11, 'createdAt' => 12, 'updatedAt' => 13, 'version' => 14, ),
+ self::TYPE_COLNAME => array(CouponVersionTableMap::ID => 0, CouponVersionTableMap::CODE => 1, CouponVersionTableMap::TYPE => 2, CouponVersionTableMap::SERIALIZED_EFFECTS => 3, CouponVersionTableMap::IS_ENABLED => 4, CouponVersionTableMap::EXPIRATION_DATE => 5, CouponVersionTableMap::MAX_USAGE => 6, CouponVersionTableMap::IS_CUMULATIVE => 7, CouponVersionTableMap::IS_REMOVING_POSTAGE => 8, CouponVersionTableMap::IS_AVAILABLE_ON_SPECIAL_OFFERS => 9, CouponVersionTableMap::IS_USED => 10, CouponVersionTableMap::SERIALIZED_CONDITIONS => 11, CouponVersionTableMap::CREATED_AT => 12, CouponVersionTableMap::UPDATED_AT => 13, CouponVersionTableMap::VERSION => 14, ),
+ self::TYPE_RAW_COLNAME => array('ID' => 0, 'CODE' => 1, 'TYPE' => 2, 'SERIALIZED_EFFECTS' => 3, 'IS_ENABLED' => 4, 'EXPIRATION_DATE' => 5, 'MAX_USAGE' => 6, 'IS_CUMULATIVE' => 7, 'IS_REMOVING_POSTAGE' => 8, 'IS_AVAILABLE_ON_SPECIAL_OFFERS' => 9, 'IS_USED' => 10, 'SERIALIZED_CONDITIONS' => 11, 'CREATED_AT' => 12, 'UPDATED_AT' => 13, 'VERSION' => 14, ),
+ self::TYPE_FIELDNAME => array('id' => 0, 'code' => 1, 'type' => 2, 'serialized_effects' => 3, 'is_enabled' => 4, 'expiration_date' => 5, 'max_usage' => 6, 'is_cumulative' => 7, 'is_removing_postage' => 8, 'is_available_on_special_offers' => 9, 'is_used' => 10, 'serialized_conditions' => 11, 'created_at' => 12, 'updated_at' => 13, 'version' => 14, ),
self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, )
);
@@ -198,7 +198,7 @@ class CouponVersionTableMap extends TableMap
$this->addForeignPrimaryKey('ID', 'Id', 'INTEGER' , 'coupon', 'ID', true, null, null);
$this->addColumn('CODE', 'Code', 'VARCHAR', true, 45, null);
$this->addColumn('TYPE', 'Type', 'VARCHAR', true, 255, null);
- $this->addColumn('AMOUNT', 'Amount', 'FLOAT', true, null, null);
+ $this->addColumn('SERIALIZED_EFFECTS', 'SerializedEffects', 'LONGVARCHAR', true, null, null);
$this->addColumn('IS_ENABLED', 'IsEnabled', 'BOOLEAN', true, 1, null);
$this->addColumn('EXPIRATION_DATE', 'ExpirationDate', 'TIMESTAMP', true, null, null);
$this->addColumn('MAX_USAGE', 'MaxUsage', 'INTEGER', true, null, null);
@@ -410,7 +410,7 @@ class CouponVersionTableMap extends TableMap
$criteria->addSelectColumn(CouponVersionTableMap::ID);
$criteria->addSelectColumn(CouponVersionTableMap::CODE);
$criteria->addSelectColumn(CouponVersionTableMap::TYPE);
- $criteria->addSelectColumn(CouponVersionTableMap::AMOUNT);
+ $criteria->addSelectColumn(CouponVersionTableMap::SERIALIZED_EFFECTS);
$criteria->addSelectColumn(CouponVersionTableMap::IS_ENABLED);
$criteria->addSelectColumn(CouponVersionTableMap::EXPIRATION_DATE);
$criteria->addSelectColumn(CouponVersionTableMap::MAX_USAGE);
@@ -426,7 +426,7 @@ class CouponVersionTableMap extends TableMap
$criteria->addSelectColumn($alias . '.ID');
$criteria->addSelectColumn($alias . '.CODE');
$criteria->addSelectColumn($alias . '.TYPE');
- $criteria->addSelectColumn($alias . '.AMOUNT');
+ $criteria->addSelectColumn($alias . '.SERIALIZED_EFFECTS');
$criteria->addSelectColumn($alias . '.IS_ENABLED');
$criteria->addSelectColumn($alias . '.EXPIRATION_DATE');
$criteria->addSelectColumn($alias . '.MAX_USAGE');
diff --git a/core/lib/Thelia/Tests/Condition/ConditionCollectionTest.php b/core/lib/Thelia/Tests/Condition/ConditionCollectionTest.php
index 46f639521..298204c26 100644
--- a/core/lib/Thelia/Tests/Condition/ConditionCollectionTest.php
+++ b/core/lib/Thelia/Tests/Condition/ConditionCollectionTest.php
@@ -26,10 +26,6 @@ use Thelia\Condition\Implementation\MatchForTotalAmount;
use Thelia\Model\CurrencyQuery;
/**
- * Created by JetBrains PhpStorm.
- * Date: 8/19/13
- * Time: 3:24 PM
- *
* Unit Test ConditionCollection Class
* Generated by PHPUnit_SkeletonGenerator 1.2.1 on 2013-11-17 at 18:59:24.
*
diff --git a/core/lib/Thelia/Tests/Condition/ConditionEvaluatorTest.php b/core/lib/Thelia/Tests/Condition/ConditionEvaluatorTest.php
index 2c85e05e5..1ecd047d5 100644
--- a/core/lib/Thelia/Tests/Condition/ConditionEvaluatorTest.php
+++ b/core/lib/Thelia/Tests/Condition/ConditionEvaluatorTest.php
@@ -28,10 +28,6 @@ use Thelia\Condition\Operators;
use Thelia\Condition\ConditionCollection;
/**
- * Created by JetBrains PhpStorm.
- * Date: 8/19/13
- * Time: 3:24 PM
- *
* Unit Test ConditionEvaluator Class
*
* @package Constraint
@@ -50,7 +46,7 @@ class ConditionEvaluatorTest extends \PHPUnit_Framework_TestCase
}
/**
- * Test vatiable comparison
+ * Test variable comparison
*
* @covers Thelia\Condition\ConditionEvaluator::variableOpComparison
*/
@@ -91,7 +87,7 @@ class ConditionEvaluatorTest extends \PHPUnit_Framework_TestCase
}
/**
- * Test vatiable comparison
+ * Test variable comparison
*
* @covers Thelia\Condition\ConditionEvaluator::variableOpComparison
*/
@@ -126,7 +122,7 @@ class ConditionEvaluatorTest extends \PHPUnit_Framework_TestCase
}
/**
- * Test vatiable comparison
+ * Test variable comparison
*
* @expectedException \Exception
* @covers Thelia\Condition\ConditionEvaluator::variableOpComparison
@@ -164,8 +160,8 @@ class ConditionEvaluatorTest extends \PHPUnit_Framework_TestCase
$collection->add($stubConditionTrue1);
$collection->add($stubConditionTrue2);
- $conitionEvaluator = new ConditionEvaluator();
- $actual = $conitionEvaluator->isMatching($collection);
+ $conditionEvaluator = new ConditionEvaluator();
+ $actual = $conditionEvaluator->isMatching($collection);
$this->assertTrue($actual);
}
@@ -195,8 +191,8 @@ class ConditionEvaluatorTest extends \PHPUnit_Framework_TestCase
$collection->add($stubConditionTrue);
$collection->add($stubConditionFalse);
- $conitionEvaluator = new ConditionEvaluator();
- $actual = $conitionEvaluator->isMatching($collection);
+ $conditionEvaluator = new ConditionEvaluator();
+ $actual = $conditionEvaluator->isMatching($collection);
$this->assertFalse($actual);
}
diff --git a/core/lib/Thelia/Tests/Condition/ConditionFactoryTest.php b/core/lib/Thelia/Tests/Condition/ConditionFactoryTest.php
index 37fde4cea..1894e8e29 100644
--- a/core/lib/Thelia/Tests/Condition/ConditionFactoryTest.php
+++ b/core/lib/Thelia/Tests/Condition/ConditionFactoryTest.php
@@ -31,10 +31,6 @@ use Thelia\Condition\ConditionCollection;
use Thelia\Model\CurrencyQuery;
/**
- * Created by JetBrains PhpStorm.
- * Date: 8/19/13
- * Time: 3:24 PM
- *
* Unit Test ConditionFactory Class
*
* @package Condition
diff --git a/core/lib/Thelia/Tests/Condition/Implementation/MatchForEveryoneTest.php b/core/lib/Thelia/Tests/Condition/Implementation/MatchForEveryoneTest.php
index f59fe04ef..fceb41f93 100644
--- a/core/lib/Thelia/Tests/Condition/Implementation/MatchForEveryoneTest.php
+++ b/core/lib/Thelia/Tests/Condition/Implementation/MatchForEveryoneTest.php
@@ -29,10 +29,6 @@ use Thelia\Coupon\FacadeInterface;
use Thelia\Model\Currency;
/**
- * Created by JetBrains PhpStorm.
- * Date: 8/19/13
- * Time: 3:24 PM
- *
* Unit Test MatchForEveryone Class
*
* @package Condition
diff --git a/core/lib/Thelia/Tests/Condition/Implementation/MatchForTotalAmountTest.php b/core/lib/Thelia/Tests/Condition/Implementation/MatchForTotalAmountTest.php
index d28bf198d..fa69e46b6 100644
--- a/core/lib/Thelia/Tests/Condition/Implementation/MatchForTotalAmountTest.php
+++ b/core/lib/Thelia/Tests/Condition/Implementation/MatchForTotalAmountTest.php
@@ -33,10 +33,6 @@ use Thelia\Model\Currency;
use Thelia\Model\CurrencyQuery;
/**
- * Created by JetBrains PhpStorm.
- * Date: 8/19/13
- * Time: 3:24 PM
- *
* Unit Test MatchForTotalAmount Class
*
* @package Condition
@@ -666,7 +662,7 @@ class MatchForTotalAmountTest extends \PHPUnit_Framework_TestCase
$collection->add($condition1);
$serialized = $conditionFactory->serializeConditionCollection($collection);
- $unserialized = $conditionFactory->unserializeConditionCollection($serialized);
+ $conditionFactory->unserializeConditionCollection($serialized);
}
/**
@@ -733,7 +729,7 @@ class MatchForTotalAmountTest extends \PHPUnit_Framework_TestCase
$collection->add($condition1);
$serialized = $conditionFactory->serializeConditionCollection($collection);
- $unserialized = $conditionFactory->unserializeConditionCollection($serialized);
+ $conditionFactory->unserializeConditionCollection($serialized);
}
/**
@@ -800,7 +796,7 @@ class MatchForTotalAmountTest extends \PHPUnit_Framework_TestCase
$collection->add($condition1);
$serialized = $conditionFactory->serializeConditionCollection($collection);
- $unserialized = $conditionFactory->unserializeConditionCollection($serialized);
+ $conditionFactory->unserializeConditionCollection($serialized);
}
/**
diff --git a/core/lib/Thelia/Tests/Condition/Implementation/MatchForXArticlesTest.php b/core/lib/Thelia/Tests/Condition/Implementation/MatchForXArticlesTest.php
index f33ef0468..4f9f96a4b 100644
--- a/core/lib/Thelia/Tests/Condition/Implementation/MatchForXArticlesTest.php
+++ b/core/lib/Thelia/Tests/Condition/Implementation/MatchForXArticlesTest.php
@@ -29,10 +29,6 @@ use Thelia\Condition\SerializableCondition;
use Thelia\Coupon\FacadeInterface;
/**
- * Created by JetBrains PhpStorm.
- * Date: 8/19/13
- * Time: 3:24 PM
- *
* Unit Test MatchForXArticles Class
*
* @package Constraint
diff --git a/core/lib/Thelia/Tests/Condition/OperatorsTest.php b/core/lib/Thelia/Tests/Condition/OperatorsTest.php
index 5d673e80b..94f5bd1bf 100644
--- a/core/lib/Thelia/Tests/Condition/OperatorsTest.php
+++ b/core/lib/Thelia/Tests/Condition/OperatorsTest.php
@@ -26,10 +26,6 @@ namespace Thelia\Condition;
use Thelia\Core\Translation\Translator;
/**
- * Created by JetBrains PhpStorm.
- * Date: 8/19/13
- * Time: 3:24 PM
- *
* Unit Test Operators Class
*
* @package Condition
diff --git a/core/lib/Thelia/Tests/Coupon/BaseFacadeTest.php b/core/lib/Thelia/Tests/Coupon/BaseFacadeTest.php
index 6e1619aac..c2082edb4 100644
--- a/core/lib/Thelia/Tests/Coupon/BaseFacadeTest.php
+++ b/core/lib/Thelia/Tests/Coupon/BaseFacadeTest.php
@@ -24,10 +24,6 @@
namespace Thelia\Coupon;
/**
- * Created by JetBrains PhpStorm.
- * Date: 8/19/13
- * Time: 3:24 PM
- *
* Unit Test BaseFacade Class
* Generated by PHPUnit_SkeletonGenerator 1.2.1 on 2013-11-17 at 18:59:24.
*
diff --git a/core/lib/Thelia/Tests/Coupon/CouponFactoryTest.php b/core/lib/Thelia/Tests/Coupon/CouponFactoryTest.php
index b70bdf247..648962e01 100644
--- a/core/lib/Thelia/Tests/Coupon/CouponFactoryTest.php
+++ b/core/lib/Thelia/Tests/Coupon/CouponFactoryTest.php
@@ -32,10 +32,6 @@ use Thelia\Model\Coupon;
use Thelia\Model\CurrencyQuery;
/**
- * Created by JetBrains PhpStorm.
- * Date: 8/19/13
- * Time: 3:24 PM
- *
* Unit Test CouponFactory Class
* Generated by PHPUnit_SkeletonGenerator 1.2.1 on 2013-11-17 at 18:59:24.
*
@@ -248,7 +244,6 @@ Sed facilisis pellentesque nisl, eu tincidunt erat scelerisque a. Nullam malesua
$stubContainer = $this->getMock('\Symfony\Component\DependencyInjection\Container');
- $conditionFactory = new ConditionFactory($stubContainer);
$stubFacade->expects($this->any())
->method('findOneCouponByCode')
->will($this->returnValue(null));
@@ -336,7 +331,7 @@ Sed facilisis pellentesque nisl, eu tincidunt erat scelerisque a. Nullam malesua
->will($this->returnValue(true));
$factory = new CouponFactory($stubContainer);
- $actual = $factory->buildCouponFromCode('XMAS');
+ $factory->buildCouponFromCode('XMAS');
}
@@ -399,7 +394,73 @@ Sed facilisis pellentesque nisl, eu tincidunt erat scelerisque a. Nullam malesua
->will($this->returnValue(true));
$factory = new CouponFactory($stubContainer);
- $actual = $factory->buildCouponFromCode('XMAS');
+ $factory->buildCouponFromCode('XMAS');
}
+
+ /**
+ * @covers Thelia\Coupon\CouponFactory::buildCouponFromModel
+ */
+ public function testBuildCouponFromModel()
+ {
+ $stubFacade = $this->generateFacadeStub();
+
+ $stubContainer = $this->getMock('\Symfony\Component\DependencyInjection\Container');
+
+ $conditionFactory = new ConditionFactory($stubContainer);
+ $couponModel = $this->generateCouponModel($stubFacade, $conditionFactory);
+ $stubFacade->expects($this->any())
+ ->method('findOneCouponByCode')
+ ->will($this->returnValue($couponModel));
+
+ $couponManager = new RemoveXAmount($stubFacade);
+
+
+ $condition1 = new MatchForTotalAmount($stubFacade);
+ $operators = array(
+ MatchForTotalAmount::INPUT1 => Operators::SUPERIOR,
+ MatchForTotalAmount::INPUT2 => Operators::EQUAL
+ );
+ $values = array(
+ MatchForTotalAmount::INPUT1 => 40.00,
+ MatchForTotalAmount::INPUT2 => 'EUR'
+ );
+ $condition1->setValidatorsFromForm($operators, $values);
+
+ $condition2 = new MatchForTotalAmount($stubFacade);
+ $operators = array(
+ MatchForTotalAmount::INPUT1 => Operators::INFERIOR,
+ MatchForTotalAmount::INPUT2 => Operators::EQUAL
+ );
+ $values = array(
+ MatchForTotalAmount::INPUT1 => 400.00,
+ MatchForTotalAmount::INPUT2 => 'EUR'
+ );
+ $condition2->setValidatorsFromForm($operators, $values);
+
+ $conditions = new ConditionCollection();
+ $conditions->add($condition1);
+ $conditions->add($condition2);
+ $stubConditionFactory = $this->getMockBuilder('\Thelia\Condition\ConditionFactory')
+ ->disableOriginalConstructor()
+ ->getMock();
+ $stubConditionFactory->expects($this->any())
+ ->method('unserializeConditionCollection')
+ ->will($this->returnValue($conditions));
+
+
+ $stubContainer->expects($this->any())
+ ->method('get')
+ ->will($this->onConsecutiveCalls($stubFacade, $couponManager, $stubConditionFactory));
+
+ $stubContainer->expects($this->any())
+ ->method('has')
+ ->will($this->returnValue(true));
+
+ $factory = new CouponFactory($stubContainer);
+ $expected = $couponManager;
+ $actual = $factory->buildCouponFromModel($couponModel);
+
+ $this->assertEquals($expected, $actual);
+ }
}
diff --git a/core/lib/Thelia/Tests/Coupon/CouponManagerTest.php b/core/lib/Thelia/Tests/Coupon/CouponManagerTest.php
index bf4b9f1e9..70d15e29a 100644
--- a/core/lib/Thelia/Tests/Coupon/CouponManagerTest.php
+++ b/core/lib/Thelia/Tests/Coupon/CouponManagerTest.php
@@ -32,10 +32,6 @@ use Thelia\Model\Coupon;
use Thelia\Model\CurrencyQuery;
/**
- * Created by JetBrains PhpStorm.
- * Date: 8/19/13
- * Time: 3:24 PM
- *
* Unit Test CouponManager Class
* Generated by PHPUnit_SkeletonGenerator 1.2.1 on 2013-11-17 at 18:59:24.
*
@@ -407,7 +403,7 @@ Sed facilisis pellentesque nisl, eu tincidunt erat scelerisque a. Nullam malesua
$coupon = new RemoveXAmount($stubFacade);
$date = new \DateTime();
- $coupon->set($stubFacade, 'XMAS', '', '', '', 21.00, true, true, true, true, 254, $date->setTimestamp(strtotime("today + 3 months")) );
+ $coupon->set($stubFacade, 'XMAS', '', '', '', array('amount' => 21.00), true, true, true, true, 254, $date->setTimestamp(strtotime("today + 3 months")) );
$condition1 = new MatchForTotalAmount($stubFacade);
$operators = array(
@@ -474,7 +470,7 @@ Sed facilisis pellentesque nisl, eu tincidunt erat scelerisque a. Nullam malesua
$coupon = new RemoveXAmount($stubFacade);
$date = new \DateTime();
- $coupon->set($stubFacade, 'XMAS', '', '', '', 21.00, true, true, true, true, 254, $date->setTimestamp(strtotime("today + 3 months")) );
+ $coupon->set($stubFacade, 'XMAS', '', '', '', array('amount' => 21.00), true, true, true, true, 254, $date->setTimestamp(strtotime("today + 3 months")) );
$condition1 = new MatchForTotalAmount($stubFacade);
$operators = array(
diff --git a/core/lib/Thelia/Tests/Coupon/Type/RemoveXAmountTest.php b/core/lib/Thelia/Tests/Coupon/Type/RemoveXAmountTest.php
index 41971d4a6..0a1d589b4 100644
--- a/core/lib/Thelia/Tests/Coupon/Type/RemoveXAmountTest.php
+++ b/core/lib/Thelia/Tests/Coupon/Type/RemoveXAmountTest.php
@@ -30,10 +30,6 @@ use Thelia\Coupon\FacadeInterface;
use Thelia\Model\CurrencyQuery;
/**
- * Created by JetBrains PhpStorm.
- * Date: 8/19/13
- * Time: 3:24 PM
- *
* Unit Test RemoveXAmount Class
* Generated by PHPUnit_SkeletonGenerator 1.2.1 on 2013-11-17 at 18:59:24.
*
@@ -129,7 +125,7 @@ class RemoveXAmountTest extends \PHPUnit_Framework_TestCase
Sed facilisis pellentesque nisl, eu tincidunt erat scelerisque a. Nullam malesuada tortor vel erat volutpat tincidunt. In vehicula diam est, a convallis eros scelerisque ut. Donec aliquet venenatis iaculis. Ut a arcu gravida, placerat dui eu, iaculis nisl. Quisque adipiscing orci sit amet dui dignissim lacinia. Sed vulputate lorem non dolor adipiscing ornare. Morbi ornare id nisl id aliquam. Ut fringilla elit ante, nec lacinia enim fermentum sit amet. Aenean rutrum lorem eu convallis pharetra. Cras malesuada varius metus, vitae gravida velit. Nam a varius ipsum, ac commodo dolor. Phasellus nec elementum elit. Etiam vel adipiscing leo.';
- $coupon->set($stubFacade, 'XMAS', 'XMAS Coupon', 'Coupon for Springbreak removing 10€ if you have a cart between 40.00€ and 400.00€ (excluded)', $description, 10.00, true, true, true, true, 254, $date->setTimestamp(strtotime("today + 3 months")) );
+ $coupon->set($stubFacade, 'XMAS', 'XMAS Coupon', 'Coupon for Springbreak removing 10€ if you have a cart between 40.00€ and 400.00€ (excluded)', $description, array('amount' => 10.00), true, true, true, true, 254, $date->setTimestamp(strtotime("today + 3 months")) );
$condition1 = new MatchForTotalAmount($stubFacade);
$operators = array(
@@ -204,6 +200,22 @@ class RemoveXAmountTest extends \PHPUnit_Framework_TestCase
$this->assertEquals($expected, $actual);
}
+ /**
+ * @covers Thelia\Coupon\Type\RemoveXPercent::getToolTip
+ */
+ public function testGetInputName()
+ {
+ $inputName = 'Amount removed from the cart';
+ $stubFacade = $this->generateFacadeStub(399, 'EUR', $inputName);
+
+ /** @var FacadeInterface $stubFacade */
+ $coupon = new RemoveXAmount($stubFacade);
+
+ $actual = $coupon->getInputName();
+ $expected = $inputName;
+ $this->assertEquals($expected, $actual);
+ }
+
/**
* Tears down the fixture, for example, closes a network connection.
* This method is called after a test is executed.
diff --git a/core/lib/Thelia/Tests/Coupon/Type/RemoveXPercentTest.php b/core/lib/Thelia/Tests/Coupon/Type/RemoveXPercentTest.php
index 475e46aba..ac893ae26 100644
--- a/core/lib/Thelia/Tests/Coupon/Type/RemoveXPercentTest.php
+++ b/core/lib/Thelia/Tests/Coupon/Type/RemoveXPercentTest.php
@@ -30,10 +30,6 @@ use Thelia\Coupon\FacadeInterface;
use Thelia\Model\CurrencyQuery;
/**
- * Created by JetBrains PhpStorm.
- * Date: 8/19/13
- * Time: 3:24 PM
- *
* Unit Test RemoveXPercent Class
* Generated by PHPUnit_SkeletonGenerator 1.2.1 on 2013-11-17 at 18:59:24.
*
@@ -119,7 +115,7 @@ class RemoveXPercentTest extends \PHPUnit_Framework_TestCase
Sed facilisis pellentesque nisl, eu tincidunt erat scelerisque a. Nullam malesuada tortor vel erat volutpat tincidunt. In vehicula diam est, a convallis eros scelerisque ut. Donec aliquet venenatis iaculis. Ut a arcu gravida, placerat dui eu, iaculis nisl. Quisque adipiscing orci sit amet dui dignissim lacinia. Sed vulputate lorem non dolor adipiscing ornare. Morbi ornare id nisl id aliquam. Ut fringilla elit ante, nec lacinia enim fermentum sit amet. Aenean rutrum lorem eu convallis pharetra. Cras malesuada varius metus, vitae gravida velit. Nam a varius ipsum, ac commodo dolor. Phasellus nec elementum elit. Etiam vel adipiscing leo.';
- $coupon->set($stubFacade, 'XMAS', 'XMAS Coupon', 'Coupon for Springbreak removing 10% if you have a cart between 40.00€ and 400.00€ (excluded)', $description, 10.00, true, true, true, true, 254, $date->setTimestamp(strtotime("today + 3 months")) );
+ $coupon->set($stubFacade, 'XMAS', 'XMAS Coupon', 'Coupon for Springbreak removing 10% if you have a cart between 40.00€ and 400.00€ (excluded)', $description, array('amount' => 0.00, 'percentage' => 10.00), true, true, true, true, 254, $date->setTimestamp(strtotime("today + 3 months")) );
$condition1 = new MatchForTotalAmount($stubFacade);
$operators = array(
@@ -160,6 +156,8 @@ class RemoveXPercentTest extends \PHPUnit_Framework_TestCase
$this->assertEquals(254, $coupon->getMaxUsage());
$this->assertEquals($date, $coupon->getExpirationDate());
+ $this->assertEquals(array(RemoveXPercent::INPUT_PERCENTAGE_NAME), $coupon->getExtendedInputs());
+
$this->assertEquals(40.00, $coupon->exec());
}
@@ -194,6 +192,22 @@ class RemoveXPercentTest extends \PHPUnit_Framework_TestCase
$this->assertEquals($expected, $actual);
}
+ /**
+ * @covers Thelia\Coupon\Type\RemoveXPercent::getToolTip
+ */
+ public function testGetInputName()
+ {
+ $inputName = 'Percentage removed from the cart';
+ $stubFacade = $this->generateFacadeStub(399, 'EUR', $inputName);
+
+ /** @var FacadeInterface $stubFacade */
+ $coupon = new RemoveXPercent($stubFacade);
+
+ $actual = $coupon->getInputName();
+ $expected = $inputName;
+ $this->assertEquals($expected, $actual);
+ }
+
/**
* Tears down the fixture, for example, closes a network connection.
* This method is called after a test is executed.
diff --git a/install/faker.php b/install/faker.php
index 30a55f397..3fd749ee1 100755
--- a/install/faker.php
+++ b/install/faker.php
@@ -7,6 +7,8 @@ use Thelia\Condition\Implementation\MatchForXArticles;
use Thelia\Condition\Operators;
use Thelia\Coupon\FacadeInterface;
use Thelia\Condition\ConditionCollection;
+use Thelia\Coupon\Type\RemoveXAmount;
+use Thelia\Coupon\Type\RemoveXPercent;
require __DIR__ . '/../core/bootstrap.php';
@@ -663,7 +665,9 @@ Duis interdum lectus nulla, nec pellentesque sapien condimentum at. Suspendisse
Praesent ligula lorem, faucibus ut metus quis, fermentum iaculis erat. Pellentesque elit erat, lacinia sed semper ac, sagittis vel elit. Nam eu convallis est. Curabitur rhoncus odio vitae consectetur pellentesque. Nam vitae arcu nec ante scelerisque dignissim vel nec neque. Suspendisse augue nulla, mollis eget dui et, tempor facilisis erat. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Morbi ac diam ipsum. Donec convallis dui ultricies velit auctor, non lobortis nulla ultrices. Morbi vitae dignissim ante, sit amet lobortis tortor. Nunc dapibus condimentum augue, in molestie neque congue non.
Sed facilisis pellentesque nisl, eu tincidunt erat scelerisque a. Nullam malesuada tortor vel erat volutpat tincidunt. In vehicula diam est, a convallis eros scelerisque ut. Donec aliquet venenatis iaculis. Ut a arcu gravida, placerat dui eu, iaculis nisl. Quisque adipiscing orci sit amet dui dignissim lacinia. Sed vulputate lorem non dolor adipiscing ornare. Morbi ornare id nisl id aliquam. Ut fringilla elit ante, nec lacinia enim fermentum sit amet. Aenean rutrum lorem eu convallis pharetra. Cras malesuada varius metus, vitae gravida velit. Nam a varius ipsum, ac commodo dolor. Phasellus nec elementum elit. Etiam vel adipiscing leo.');
- $coupon1->setAmount(10.00);
+ $coupon1->setEffects(array(
+ RemoveXAmount::INPUT_AMOUNT_NAME => 10.00,
+ ));
$coupon1->setIsUsed(true);
$coupon1->setIsEnabled(true);
$date = new \DateTime();
@@ -721,7 +725,10 @@ Duis interdum lectus nulla, nec pellentesque sapien condimentum at. Suspendisse
Praesent ligula lorem, faucibus ut metus quis, fermentum iaculis erat. Pellentesque elit erat, lacinia sed semper ac, sagittis vel elit. Nam eu convallis est. Curabitur rhoncus odio vitae consectetur pellentesque. Nam vitae arcu nec ante scelerisque dignissim vel nec neque. Suspendisse augue nulla, mollis eget dui et, tempor facilisis erat. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Morbi ac diam ipsum. Donec convallis dui ultricies velit auctor, non lobortis nulla ultrices. Morbi vitae dignissim ante, sit amet lobortis tortor. Nunc dapibus condimentum augue, in molestie neque congue non.
Sed facilisis pellentesque nisl, eu tincidunt erat scelerisque a. Nullam malesuada tortor vel erat volutpat tincidunt. In vehicula diam est, a convallis eros scelerisque ut. Donec aliquet venenatis iaculis. Ut a arcu gravida, placerat dui eu, iaculis nisl. Quisque adipiscing orci sit amet dui dignissim lacinia. Sed vulputate lorem non dolor adipiscing ornare. Morbi ornare id nisl id aliquam. Ut fringilla elit ante, nec lacinia enim fermentum sit amet. Aenean rutrum lorem eu convallis pharetra. Cras malesuada varius metus, vitae gravida velit. Nam a varius ipsum, ac commodo dolor. Phasellus nec elementum elit. Etiam vel adipiscing leo.');
- $coupon2->setAmount(10.00);
+ $coupon2->setEffects(array(
+ RemoveXPercent::INPUT_AMOUNT_NAME => 0.00,
+ RemoveXPercent::INPUT_PERCENTAGE_NAME => 10.00,
+ ));
$coupon2->setIsUsed(true);
$coupon2->setIsEnabled(true);
$date = new \DateTime();
@@ -765,7 +772,10 @@ Duis interdum lectus nulla, nec pellentesque sapien condimentum at. Suspendisse
Praesent ligula lorem, faucibus ut metus quis, fermentum iaculis erat. Pellentesque elit erat, lacinia sed semper ac, sagittis vel elit. Nam eu convallis est. Curabitur rhoncus odio vitae consectetur pellentesque. Nam vitae arcu nec ante scelerisque dignissim vel nec neque. Suspendisse augue nulla, mollis eget dui et, tempor facilisis erat. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Morbi ac diam ipsum. Donec convallis dui ultricies velit auctor, non lobortis nulla ultrices. Morbi vitae dignissim ante, sit amet lobortis tortor. Nunc dapibus condimentum augue, in molestie neque congue non.
Sed facilisis pellentesque nisl, eu tincidunt erat scelerisque a. Nullam malesuada tortor vel erat volutpat tincidunt. In vehicula diam est, a convallis eros scelerisque ut. Donec aliquet venenatis iaculis. Ut a arcu gravida, placerat dui eu, iaculis nisl. Quisque adipiscing orci sit amet dui dignissim lacinia. Sed vulputate lorem non dolor adipiscing ornare. Morbi ornare id nisl id aliquam. Ut fringilla elit ante, nec lacinia enim fermentum sit amet. Aenean rutrum lorem eu convallis pharetra. Cras malesuada varius metus, vitae gravida velit. Nam a varius ipsum, ac commodo dolor. Phasellus nec elementum elit. Etiam vel adipiscing leo.');
- $coupon3->setAmount(10.00);
+ $coupon3->setEffects(array(
+ RemoveXPercent::INPUT_AMOUNT_NAME => 0.00,
+ RemoveXPercent::INPUT_PERCENTAGE_NAME => 10.00,
+ ));
$coupon3->setIsUsed(false);
$coupon3->setIsEnabled(false);
$date = new \DateTime();
diff --git a/install/thelia.sql b/install/thelia.sql
index 1d0ecfb63..bf3b2dd15 100755
--- a/install/thelia.sql
+++ b/install/thelia.sql
@@ -1084,7 +1084,7 @@ CREATE TABLE `coupon`
`id` INTEGER NOT NULL AUTO_INCREMENT,
`code` VARCHAR(45) NOT NULL,
`type` VARCHAR(255) NOT NULL,
- `amount` FLOAT NOT NULL,
+ `serialized_effects` TEXT NOT NULL,
`is_enabled` TINYINT(1) NOT NULL,
`expiration_date` DATETIME NOT NULL,
`max_usage` INTEGER NOT NULL,
@@ -1101,7 +1101,6 @@ CREATE TABLE `coupon`
INDEX `idx_is_enabled` (`is_enabled`),
INDEX `idx_is_used` (`is_used`),
INDEX `idx_type` (`type`),
- INDEX `idx_amount` (`amount`),
INDEX `idx_expiration_date` (`expiration_date`),
INDEX `idx_is_cumulative` (`is_cumulative`),
INDEX `idx_is_removing_postage` (`is_removing_postage`),
@@ -2385,7 +2384,7 @@ CREATE TABLE `coupon_version`
`id` INTEGER NOT NULL,
`code` VARCHAR(45) NOT NULL,
`type` VARCHAR(255) NOT NULL,
- `amount` FLOAT NOT NULL,
+ `serialized_effects` TEXT NOT NULL,
`is_enabled` TINYINT(1) NOT NULL,
`expiration_date` DATETIME NOT NULL,
`max_usage` INTEGER NOT NULL,
diff --git a/local/config/schema.xml b/local/config/schema.xml
index 1613abafc..08322de99 100755
--- a/local/config/schema.xml
+++ b/local/config/schema.xml
@@ -1,4 +1,4 @@
-
+