diff --git a/CHANGELOG.md b/CHANGELOG.md index 7797282d0..126793148 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,13 @@ +#2.0.2 +- New coupon conditions : + - Start date + - Billing country + - Shipping country + - Cart contains product + - Cart contains product from category + - For specific customers + + #2.0.1 - possibility to apply a permanent discount on a customer - display estimated shipping on cart page diff --git a/core/lib/Thelia/Condition/ConditionEvaluator.php b/core/lib/Thelia/Condition/ConditionEvaluator.php index 455537ee8..9960b3aa5 100644 --- a/core/lib/Thelia/Condition/ConditionEvaluator.php +++ b/core/lib/Thelia/Condition/ConditionEvaluator.php @@ -37,6 +37,7 @@ class ConditionEvaluator foreach ($conditions as $condition) { if (!$condition->isMatching()) { $isMatching = false; + break; } } diff --git a/core/lib/Thelia/Condition/ConditionFactory.php b/core/lib/Thelia/Condition/ConditionFactory.php index 8fd9647b6..12bc179a2 100644 --- a/core/lib/Thelia/Condition/ConditionFactory.php +++ b/core/lib/Thelia/Condition/ConditionFactory.php @@ -83,7 +83,8 @@ class ConditionFactory $collection = new ConditionCollection(); - if (!empty($unserializedConditions) && !empty($unserializedConditions)) { + if (!empty($unserializedConditions)) { + /** @var SerializableCondition $condition */ foreach ($unserializedConditions as $condition) { if ($this->container->has($condition->conditionServiceId)) { diff --git a/core/lib/Thelia/Condition/Implementation/AbstractMatchCountries.php b/core/lib/Thelia/Condition/Implementation/AbstractMatchCountries.php new file mode 100644 index 000000000..0e35b16d1 --- /dev/null +++ b/core/lib/Thelia/Condition/Implementation/AbstractMatchCountries.php @@ -0,0 +1,150 @@ + + * + */ +abstract class AbstractMatchCountries extends ConditionAbstract +{ + /** Condition 1st parameter : quantity */ + CONST COUNTRIES_LIST = 'countries'; + + /** + * @inheritdoc + */ + public function __construct(FacadeInterface $facade) + { + $this->availableOperators = [ + self::COUNTRIES_LIST => [ + Operators::IN, + Operators::OUT + ] + ]; + + parent::__construct($facade); + } + + protected abstract function getSummaryLabel($cntryStrList, $i18nOperator); + + protected abstract function getFormLabel(); + + /** + * @inheritdoc + */ + public function setValidatorsFromForm(array $operators, array $values) + { + $this->checkComparisonOperatorValue($operators, self::COUNTRIES_LIST); + + // Use default values if data is not defined. + if (! isset($operators[self::COUNTRIES_LIST]) || ! isset($values[self::COUNTRIES_LIST])) { + $operators[self::COUNTRIES_LIST] = Operators::IN; + $values[self::COUNTRIES_LIST] = []; + } + + // Be sure that the value is an array, make one if required + if (! is_array($values[self::COUNTRIES_LIST])) { + $values[self::COUNTRIES_LIST] = array($values[self::COUNTRIES_LIST]); + } + + // Check that at least one category is selected + if (empty($values[self::COUNTRIES_LIST])) { + throw new InvalidConditionValueException( + get_class(), self::COUNTRIES_LIST + ); + } + + $this->operators = [ self::COUNTRIES_LIST => $operators[self::COUNTRIES_LIST] ]; + $this->values = [ self::COUNTRIES_LIST => $values[self::COUNTRIES_LIST] ]; + + return $this; + } + + /** + * @inheritdoc + */ + public function isMatching() + { + // The delivery address should match one of the selected countries. + + /* TODO !!!! */ + return $this->conditionValidator->variableOpComparison( + $this->facade->getNbArticlesInCart(), + $this->operators[self::COUNTRIES_LIST], + $this->values[self::COUNTRIES_LIST] + ); + } + + /** + * @inheritdoc + */ + public function getSummary() + { + $i18nOperator = Operators::getI18n( + $this->translator, $this->operators[self::COUNTRIES_LIST] + ); + + $cntryStrList = ''; + + $cntryIds = $this->values[self::COUNTRIES_LIST]; + + if (null !== $cntryList = CountryQuery::create()->findPks($cntryIds)) { + + /** @var Category $cntry */ + foreach($cntryList as $cntry) { + $cntryStrList .= $cntry->getTitle() . ', '; + } + + $cntryStrList = rtrim($cntryStrList, ', '); + } + + return $this->getSummaryLabel($cntryStrList, $i18nOperator); + } + + /** + * @inheritdoc + */ + protected function generateInputs() + { + return array( + self::COUNTRIES_LIST => array( + 'availableOperators' => $this->availableOperators[self::COUNTRIES_LIST], + 'value' => '', + 'selectedOperator' => Operators::IN + ) + ); + } + + /** + * @inheritdoc + */ + public function drawBackOfficeInputs() + { + return $this->facade->getParser()->render('coupon/condition-fragments/countries-condition.html', [ + 'operatorSelectHtml' => $this->drawBackOfficeInputOperators(self::COUNTRIES_LIST), + 'countries_field_name' => self::COUNTRIES_LIST, + 'values' => isset($this->values[self::COUNTRIES_LIST]) ? $this->values[self::COUNTRIES_LIST] : array(), + 'countryLabel' => $this->getFormLabel() + ] + ); + } +} \ No newline at end of file diff --git a/core/lib/Thelia/Condition/Implementation/CartContainsCategories.php b/core/lib/Thelia/Condition/Implementation/CartContainsCategories.php new file mode 100644 index 000000000..010b4f9ba --- /dev/null +++ b/core/lib/Thelia/Condition/Implementation/CartContainsCategories.php @@ -0,0 +1,202 @@ + + * + */ +class CartContainsCategories extends ConditionAbstract +{ + /** Condition 1st parameter : quantity */ + CONST CATEGORIES_LIST = 'categories'; + + /** + * @inheritdoc + */ + public function __construct(FacadeInterface $facade) + { + $this->availableOperators = [ + self::CATEGORIES_LIST => [ + Operators::IN, + Operators::OUT + ] + ]; + + parent::__construct($facade); + } + + /** + * @inheritdoc + */ + public function getServiceId() + { + return 'thelia.condition.cart_contains_categories'; + } + + /** + * @inheritdoc + */ + public function setValidatorsFromForm(array $operators, array $values) + { + $this->checkComparisonOperatorValue($operators, self::CATEGORIES_LIST); + + // Use default values if data is not defined. + if (! isset($operators[self::CATEGORIES_LIST]) || ! isset($values[self::CATEGORIES_LIST])) { + $operators[self::CATEGORIES_LIST] = Operators::IN; + $values[self::CATEGORIES_LIST] = []; + } + + // Be sure that the value is an array, make one if required + if (! is_array($values[self::CATEGORIES_LIST])) { + $values[self::CATEGORIES_LIST] = array($values[self::CATEGORIES_LIST]); + } + + // Check that at least one category is selected + if (empty($values[self::CATEGORIES_LIST])) { + throw new InvalidConditionValueException( + get_class(), self::CATEGORIES_LIST + ); + } + + $this->operators = [ self::CATEGORIES_LIST => $operators[self::CATEGORIES_LIST] ]; + $this->values = [ self::CATEGORIES_LIST => $values[self::CATEGORIES_LIST] ]; + + return $this; + } + + /** + * @inheritdoc + */ + public function isMatching() + { + $cartItems = $this->facade->getCart()->getCartItems(); + + /** @var CartItem $cartItem */ + foreach($cartItems as $cartItem) { + + $categories = $cartItem->getProduct()->getCategories(); + + /** @var Category $category */ + foreach($categories as $category) { + $catecoryInCart = $this->conditionValidator->variableOpComparison( + $category->getId(), + $this->operators[self::CATEGORIES_LIST], + $this->values[self::CATEGORIES_LIST] + ); + + if ($catecoryInCart) { + return true; + } + } + } + + return false; + } + + /** + * @inheritdoc + */ + public function getName() + { + return $this->translator->trans( + 'Cart contains categories condition', + [], + 'condition' + ); + } + + /** + * @inheritdoc + */ + public function getToolTip() + { + $toolTip = $this->translator->trans( + 'The coupon applies if the cart contains at least one product of the selected categories', + [], + 'condition' + ); + + return $toolTip; + } + + /** + * @inheritdoc + */ + public function getSummary() + { + $i18nOperator = Operators::getI18n( + $this->translator, $this->operators[self::CATEGORIES_LIST] + ); + + $catStrList = ''; + + $catIds = $this->values[self::CATEGORIES_LIST]; + + if (null !== $catList = CategoryQuery::create()->findPks($catIds)) { + + /** @var Category $cat */ + foreach($catList as $cat) { + $catStrList .= $cat->getTitle() . ', '; + } + + $catStrList = rtrim($catStrList, ', '); + } + + $toolTip = $this->translator->trans( + 'At least one of cart products categories is %op% %categories_list%', [ + '%categories_list%' => $catStrList, + '%op%' => $i18nOperator + ], 'condition' + ); + + return $toolTip; + } + + /** + * @inheritdoc + */ + protected function generateInputs() + { + return array( + self::CATEGORIES_LIST => array( + 'availableOperators' => $this->availableOperators[self::CATEGORIES_LIST], + 'value' => '', + 'selectedOperator' => Operators::IN + ) + ); + } + + /** + * @inheritdoc + */ + public function drawBackOfficeInputs() + { + return $this->facade->getParser()->render('coupon/condition-fragments/cart-contains-categories-condition.html', [ + 'operatorSelectHtml' => $this->drawBackOfficeInputOperators(self::CATEGORIES_LIST), + 'categories_field_name' => self::CATEGORIES_LIST, + 'values' => isset($this->values[self::CATEGORIES_LIST]) ? $this->values[self::CATEGORIES_LIST] : array() + ] + ); + } +} diff --git a/core/lib/Thelia/Condition/Implementation/CartContainsProducts.php b/core/lib/Thelia/Condition/Implementation/CartContainsProducts.php new file mode 100644 index 000000000..6fd495b72 --- /dev/null +++ b/core/lib/Thelia/Condition/Implementation/CartContainsProducts.php @@ -0,0 +1,195 @@ + + * + */ +class CartContainsProducts extends ConditionAbstract +{ + /** Condition 1st parameter : quantity */ + const PRODUCTS_LIST = 'products'; + + /** + * @inheritdoc + */ + public function __construct(FacadeInterface $facade) + { + $this->availableOperators = [ + self::PRODUCTS_LIST => [ + Operators::IN, + Operators::OUT + ] + ]; + + parent::__construct($facade); + } + + /** + * @inheritdoc + */ + public function getServiceId() + { + return 'thelia.condition.cart_contains_products'; + } + + /** + * @inheritdoc + */ + public function setValidatorsFromForm(array $operators, array $values) + { + $this->checkComparisonOperatorValue($operators, self::PRODUCTS_LIST); + + // Use default values if data is not defined. + if (! isset($operators[self::PRODUCTS_LIST]) || ! isset($values[self::PRODUCTS_LIST])) { + $operators[self::PRODUCTS_LIST] = Operators::IN; + $values[self::PRODUCTS_LIST] = []; + } + + // Be sure that the value is an array, make one if required + if (! is_array($values[self::PRODUCTS_LIST])) { + $values[self::PRODUCTS_LIST] = array($values[self::PRODUCTS_LIST]); + } + + // Check that at least one product is selected + if (empty($values[self::PRODUCTS_LIST])) { + throw new InvalidConditionValueException( + get_class(), self::PRODUCTS_LIST + ); + } + + $this->operators = [ self::PRODUCTS_LIST => $operators[self::PRODUCTS_LIST] ]; + $this->values = [ self::PRODUCTS_LIST => $values[self::PRODUCTS_LIST] ]; + + return $this; + } + + /** + * @inheritdoc + */ + public function isMatching() + { + $cartItems = $this->facade->getCart()->getCartItems(); + + /** @var CartItem $cartItem */ + foreach($cartItems as $cartItem) { + + if ($this->conditionValidator->variableOpComparison( + $cartItem->getProduct()->getId(), + $this->operators[self::PRODUCTS_LIST], + $this->values[self::PRODUCTS_LIST])) { + + return true; + } + } + + return false; + } + + /** + * @inheritdoc + */ + public function getName() + { + return $this->translator->trans( + 'Cart contains specific products', + [], + 'condition' + ); + } + + /** + * @inheritdoc + */ + public function getToolTip() + { + $toolTip = $this->translator->trans( + 'The coupon applies if the cart contains at least one product of the specified product list', + [], + 'condition' + ); + + return $toolTip; + } + + /** + * @inheritdoc + */ + public function getSummary() + { + $i18nOperator = Operators::getI18n( + $this->translator, $this->operators[self::PRODUCTS_LIST] + ); + + $prodStrList = ''; + + $prodIds = $this->values[self::PRODUCTS_LIST]; + + if (null !== $prodList = ProductQuery::create()->findPks($prodIds)) { + + /** @var Product $prod */ + foreach($prodList as $prod) { + $prodStrList .= $prod->getTitle() . ', '; + } + + $prodStrList = rtrim($prodStrList, ', '); + } + + $toolTip = $this->translator->trans( + 'Cart contains at least a product %op% %products_list%', [ + '%products_list%' => $prodStrList, + '%op%' => $i18nOperator + ], 'condition' + ); + + return $toolTip; + } + + /** + * @inheritdoc + */ + protected function generateInputs() + { + return array( + self::PRODUCTS_LIST => array( + 'availableOperators' => $this->availableOperators[self::PRODUCTS_LIST], + 'value' => '', + 'selectedOperator' => Operators::IN + ) + ); + } + + /** + * @inheritdoc + */ + public function drawBackOfficeInputs() + { + return $this->facade->getParser()->render('coupon/condition-fragments/cart-contains-products-condition.html', [ + 'operatorSelectHtml' => $this->drawBackOfficeInputOperators(self::PRODUCTS_LIST), + 'products_field_name' => self::PRODUCTS_LIST, + 'values' => isset($this->values[self::PRODUCTS_LIST]) ? $this->values[self::PRODUCTS_LIST] : array() + ] + ); + } +} diff --git a/core/lib/Thelia/Condition/Implementation/ConditionAbstract.php b/core/lib/Thelia/Condition/Implementation/ConditionAbstract.php index e5ebd6746..d5064d081 100644 --- a/core/lib/Thelia/Condition/Implementation/ConditionAbstract.php +++ b/core/lib/Thelia/Condition/Implementation/ConditionAbstract.php @@ -17,6 +17,7 @@ use Thelia\Condition\Operators; use Thelia\Condition\SerializableCondition; use Thelia\Core\Translation\Translator; use Thelia\Coupon\FacadeInterface; +use Thelia\Exception\InvalidConditionOperatorException; use Thelia\Exception\InvalidConditionValueException; use Thelia\Model\Base\CurrencyQuery; use Thelia\Model\Currency; @@ -31,10 +32,6 @@ use Thelia\Type\FloatType; */ abstract class ConditionAbstract implements ConditionInterface { - - /** @var string Service Id from Resources/config.xml */ - protected $serviceId = null; - /** @var array Available Operators (Operators::CONST) */ protected $availableOperators = []; @@ -69,13 +66,27 @@ abstract class ConditionAbstract implements ConditionInterface } /** - * Return all available Operators for this Condition + * @param array $operatorList the list of comparison operator values, as entered in the condition parameter form + * @param string $parameterName the name of the parameter to check * - * @return array Operators::CONST + * @return $this + * + * @throws \Thelia\Exception\InvalidConditionOperatorException if the operator value is not in the allowed value */ - public function getAvailableOperators() - { - return $this->availableOperators; + protected function checkComparisonOperatorValue($operatorList, $parameterName) { + + $isOperator1Legit = $this->isOperatorLegit( + $operatorList[$parameterName], + $this->availableOperators[$parameterName] + ); + + if (!$isOperator1Legit) { + throw new InvalidConditionOperatorException( + get_class(), $parameterName + ); + } + + return $this; } /** @@ -88,8 +99,11 @@ abstract class ConditionAbstract implements ConditionInterface $this->validators = $this->generateInputs(); $translatedInputs = []; + foreach ($this->validators as $key => $validator) { + $translatedOperators = []; + foreach ($validator['availableOperators'] as $availableOperators) { $translatedOperators[$availableOperators] = Operators::getI18n( $this->translator, @@ -98,18 +112,23 @@ abstract class ConditionAbstract implements ConditionInterface } $validator['availableOperators'] = $translatedOperators; + $translatedInputs[$key] = $validator; } - $validators = []; - $validators['inputs'] = $translatedInputs; - $validators['setOperators'] = $this->operators; - $validators['setValues'] = $this->values; + + $validators = [ + 'inputs' => $translatedInputs, + 'setOperators' => $this->operators, + 'setValues' => $this->values + ]; return $validators; } /** - * Generate inputs ready to be drawn + * Generate inputs ready to be drawn. + * + * TODO: what these "inputs ready to be drawn" is not clear. * * @throws \Thelia\Exception\NotImplementedException * @return array @@ -128,7 +147,9 @@ abstract class ConditionAbstract implements ConditionInterface */ public function getServiceId() { - return $this->serviceId; + throw new \Thelia\Exception\NotImplementedException( + 'The getServiceId method must be implemented in ' . get_class() + ); } /** @@ -152,7 +173,7 @@ abstract class ConditionAbstract implements ConditionInterface public function getSerializableCondition() { $serializableCondition = new SerializableCondition(); - $serializableCondition->conditionServiceId = $this->serviceId; + $serializableCondition->conditionServiceId = $this->getServiceId(); $serializableCondition->operators = $this->operators; $serializableCondition->values = $this->values; diff --git a/core/lib/Thelia/Condition/Implementation/ConditionInterface.php b/core/lib/Thelia/Condition/Implementation/ConditionInterface.php index 209a403f9..f1d839cb9 100644 --- a/core/lib/Thelia/Condition/Implementation/ConditionInterface.php +++ b/core/lib/Thelia/Condition/Implementation/ConditionInterface.php @@ -14,6 +14,8 @@ namespace Thelia\Condition\Implementation; use Thelia\Condition\SerializableCondition; use Thelia\Coupon\FacadeInterface; +use Thelia\Exception\InvalidConditionOperatorException; +use Thelia\Exception\InvalidConditionValueException; /** * Manage how the application checks its state in order to check if it matches the implemented condition @@ -41,10 +43,12 @@ interface ConditionInterface /** * Check validators relevancy and store them * - * @param array $operators Operators the Admin set in BackOffice - * @param array $values Values the Admin set in BackOffice + * @param array $operators an array of operators (greater than, less than, etc.) entered in the condition parameter input form, one for each condition defined by the Condition + * @param array $values an array of values entered in in the condition parameter input form, one for each condition defined by the Condition + * + * @throws InvalidConditionOperatorException + * @throws InvalidConditionValueException * - * @throws \InvalidArgumentException * @return $this */ public function setValidatorsFromForm(array $operators, array $values); @@ -56,13 +60,6 @@ interface ConditionInterface */ public function isMatching(); - /** - * Return all available Operators for this condition - * - * @return array Operators::CONST - */ - public function getAvailableOperators(); - /** * Get I18n name * @@ -107,5 +104,4 @@ interface ConditionInterface * @return string HTML string */ public function drawBackOfficeInputs(); - } diff --git a/core/lib/Thelia/Condition/Implementation/ForSomeCustomers.php b/core/lib/Thelia/Condition/Implementation/ForSomeCustomers.php new file mode 100644 index 000000000..7d77ed103 --- /dev/null +++ b/core/lib/Thelia/Condition/Implementation/ForSomeCustomers.php @@ -0,0 +1,185 @@ + + * + */ +class ForSomeCustomers extends ConditionAbstract +{ + const CUSTOMERS_LIST = 'customers'; + + /** + * @inheritdoc + */ + public function __construct(FacadeInterface $facade) + { + $this->availableOperators = [ + self::CUSTOMERS_LIST => [ + Operators::IN, + Operators::OUT + ] + ]; + + parent::__construct($facade); + } + + /** + * @inheritdoc + */ + public function getServiceId() + { + return 'thelia.condition.for_some_customers'; + } + + /** + * @inheritdoc + */ + public function setValidatorsFromForm(array $operators, array $values) + { + $this->checkComparisonOperatorValue($operators, self::CUSTOMERS_LIST); + + // Use default values if data is not defined. + if (! isset($operators[self::CUSTOMERS_LIST]) || ! isset($values[self::CUSTOMERS_LIST])) { + $operators[self::CUSTOMERS_LIST] = Operators::IN; + $values[self::CUSTOMERS_LIST] = []; + } + + // Be sure that the value is an array, make one if required + if (! is_array($values[self::CUSTOMERS_LIST])) { + $values[self::CUSTOMERS_LIST] = array($values[self::CUSTOMERS_LIST]); + } + + // Check that at least one product is selected + if (empty($values[self::CUSTOMERS_LIST])) { + throw new InvalidConditionValueException( + get_class(), self::CUSTOMERS_LIST + ); + } + + $this->operators = [ self::CUSTOMERS_LIST => $operators[self::CUSTOMERS_LIST] ]; + $this->values = [ self::CUSTOMERS_LIST => $values[self::CUSTOMERS_LIST] ]; + + return $this; + } + + /** + * @inheritdoc + */ + public function isMatching() + { + $customer = $this->facade->getCustomer(); + + return $this->conditionValidator->variableOpComparison( + $customer->getId(), + $this->operators[self::CUSTOMERS_LIST], + $this->values[self::CUSTOMERS_LIST] + ); + } + + /** + * @inheritdoc + */ + public function getName() + { + return $this->translator->trans( + 'For one ore more customers', + [], + 'condition' + ); + } + + /** + * @inheritdoc + */ + public function getToolTip() + { + $toolTip = $this->translator->trans( + 'The coupon applies to some customers only', + [], + 'condition' + ); + + return $toolTip; + } + + /** + * @inheritdoc + */ + public function getSummary() + { + $i18nOperator = Operators::getI18n( + $this->translator, $this->operators[self::CUSTOMERS_LIST] + ); + + $custStrList = ''; + + $custIds = $this->values[self::CUSTOMERS_LIST]; + + if (null !== $custList = CustomerQuery::create()->findPks($custIds)) { + + /** @var Customer $cust */ + foreach($custList as $cust) { + $custStrList .= $cust->getLastname() . ' ' . $cust->getFirstname() . ' ('.$cust->getRef().'), '; + } + + $custStrList = rtrim($custStrList, ', '); + } + + $toolTip = $this->translator->trans( + 'Customer is %op% %customer_list%', [ + '%customer_list%' => $custStrList, + '%op%' => $i18nOperator + ], 'condition' + ); + + return $toolTip; + } + + /** + * @inheritdoc + */ + protected function generateInputs() + { + return array( + self::CUSTOMERS_LIST => array( + 'availableOperators' => $this->availableOperators[self::CUSTOMERS_LIST], + 'value' => '', + 'selectedOperator' => Operators::IN + ) + ); + } + + /** + * @inheritdoc + */ + public function drawBackOfficeInputs() + { + return $this->facade->getParser()->render('coupon/condition-fragments/customers-condition.html', [ + 'operatorSelectHtml' => $this->drawBackOfficeInputOperators(self::CUSTOMERS_LIST), + 'customers_field_name' => self::CUSTOMERS_LIST, + 'values' => isset($this->values[self::CUSTOMERS_LIST]) ? $this->values[self::CUSTOMERS_LIST] : array() + ] + ); + } +} diff --git a/core/lib/Thelia/Condition/Implementation/MatchBillingCountries.php b/core/lib/Thelia/Condition/Implementation/MatchBillingCountries.php new file mode 100644 index 000000000..ffd067815 --- /dev/null +++ b/core/lib/Thelia/Condition/Implementation/MatchBillingCountries.php @@ -0,0 +1,87 @@ + + * + */ +class MatchBillingCountries extends AbstractMatchCountries +{ + /** + * @inheritdoc + */ + public function getServiceId() + { + return 'thelia.condition.match_billing_countries'; + } + + /** + * @inheritdoc + */ + public function isMatching() + { + $billingAddress = $this->facade->getCustomer()->getDefaultAddress(); + + return $this->conditionValidator->variableOpComparison( + $billingAddress->getCountryId(), + $this->operators[self::COUNTRIES_LIST], + $this->values[self::COUNTRIES_LIST] + ); + } + + /** + * @inheritdoc + */ + public function getName() + { + return $this->translator->trans( + 'Billing country', + [], + 'condition' + ); + } + + /** + * @inheritdoc + */ + public function getToolTip() + { + $toolTip = $this->translator->trans( + 'The coupon applies to the selected delivery countries', + [], + 'condition' + ); + + return $toolTip; + } + + protected function getSummaryLabel($cntryStrList, $i18nOperator) { + + return $this->translator->trans( + 'Only if order billing country is %op% %countries_list%', [ + '%countries_list%' => $cntryStrList, + '%op%' => $i18nOperator + ], 'condition' + ); + } + + protected function getFormLabel() { + return $this->translator->trans( + 'Billing coutry is', [], 'condition' + ); + } +} diff --git a/core/lib/Thelia/Condition/Implementation/MatchDeliveryCountries.php b/core/lib/Thelia/Condition/Implementation/MatchDeliveryCountries.php new file mode 100644 index 000000000..519cc3ade --- /dev/null +++ b/core/lib/Thelia/Condition/Implementation/MatchDeliveryCountries.php @@ -0,0 +1,87 @@ + + * + */ +class MatchDeliveryCountries extends AbstractMatchCountries +{ + /** + * @inheritdoc + */ + public function getServiceId() + { + return 'thelia.condition.match_delivery_countries'; + } + + /** + * @inheritdoc + */ + public function isMatching() + { + $deliveryAddress = $this->facade->getDeliveryAddress(); + + return $this->conditionValidator->variableOpComparison( + $deliveryAddress->getCountryId(), + $this->operators[self::COUNTRIES_LIST], + $this->values[self::COUNTRIES_LIST] + ); + } + + /** + * @inheritdoc + */ + public function getName() + { + return $this->translator->trans( + 'Delivery country', + [], + 'condition' + ); + } + + /** + * @inheritdoc + */ + public function getToolTip() + { + $toolTip = $this->translator->trans( + 'The coupon applies to the selected delivery countries', + [], + 'condition' + ); + + return $toolTip; + } + + protected function getSummaryLabel($cntryStrList, $i18nOperator) { + + return $this->translator->trans( + 'Only if order shipping country is %op% %countries_list%', [ + '%countries_list%' => $cntryStrList, + '%op%' => $i18nOperator + ], 'condition' + ); + } + + protected function getFormLabel() { + return $this->translator->trans( + 'Delivery coutry is', [], 'condition' + ); + } +} diff --git a/core/lib/Thelia/Condition/Implementation/MatchForEveryone.php b/core/lib/Thelia/Condition/Implementation/MatchForEveryone.php index 5049470a2..f85ea4350 100644 --- a/core/lib/Thelia/Condition/Implementation/MatchForEveryone.php +++ b/core/lib/Thelia/Condition/Implementation/MatchForEveryone.php @@ -12,6 +12,8 @@ namespace Thelia\Condition\Implementation; +use Thelia\Coupon\FacadeInterface; + /** * Allow every one, perform no check * @@ -21,35 +23,29 @@ namespace Thelia\Condition\Implementation; */ class MatchForEveryone extends ConditionAbstract { - /** @var string Service Id from Resources/config.xml */ - protected $serviceId = 'thelia.condition.match_for_everyone'; - - /** @var array Available Operators (Operators::CONST) */ - protected $availableOperators = []; - /** - * Check validators relevancy and store them - * - * @param array $operators Operators the Admin set in BackOffice - * @param array $values Values the Admin set in BackOffice - * - * @throws \InvalidArgumentException - * @return $this + * @inheritdoc */ - public function setValidatorsFromForm(array $operators, array $values) - { - $this->setValidators(); + public function __construct(FacadeInterface $facade) { - return $this; + // Define the allowed comparison operators + $this->availableOperators = []; + + parent::__construct($facade); } /** - * Check validators relevancy and store them - * - * @throws \InvalidArgumentException - * @return $this + * @inheritdoc */ - protected function setValidators() + public function getServiceId() + { + return 'thelia.condition.match_for_everyone'; + } + + /** + * @inheritdoc + */ + public function setValidatorsFromForm(array $operators, array $values) { $this->operators = []; $this->values = []; @@ -58,9 +54,7 @@ class MatchForEveryone extends ConditionAbstract } /** - * Test if Customer meets conditions - * - * @return bool + * @inheritdoc */ public function isMatching() { @@ -68,9 +62,7 @@ class MatchForEveryone extends ConditionAbstract } /** - * Get I18n name - * - * @return string + * @inheritdoc */ public function getName() { @@ -82,10 +74,7 @@ class MatchForEveryone extends ConditionAbstract } /** - * Get I18n tooltip - * Explain in detail what the Condition checks - * - * @return string + * @inheritdoc */ public function getToolTip() { @@ -99,10 +88,7 @@ class MatchForEveryone extends ConditionAbstract } /** - * Get I18n summary - * Explain briefly the condition with given values - * - * @return string + * @inheritdoc */ public function getSummary() { @@ -116,20 +102,15 @@ class MatchForEveryone extends ConditionAbstract } /** - * Generate inputs ready to be drawn - * - * @return array - */ + * @inheritdoc + */ protected function generateInputs() { return []; } /** - * Draw the input displayed in the BackOffice - * allowing Admin to set its Coupon Conditions - * - * @return string HTML string + * @inheritdoc */ public function drawBackOfficeInputs() { diff --git a/core/lib/Thelia/Condition/Implementation/MatchForTotalAmount.php b/core/lib/Thelia/Condition/Implementation/MatchForTotalAmount.php index 26939193c..225157b38 100644 --- a/core/lib/Thelia/Condition/Implementation/MatchForTotalAmount.php +++ b/core/lib/Thelia/Condition/Implementation/MatchForTotalAmount.php @@ -13,7 +13,7 @@ namespace Thelia\Condition\Implementation; use Thelia\Condition\Operators; -use Thelia\Exception\InvalidConditionOperatorException; +use Thelia\Coupon\FacadeInterface; use Thelia\Model\Currency; use Thelia\Model\CurrencyQuery; @@ -22,99 +22,64 @@ use Thelia\Model\CurrencyQuery; * Check if a Checkout total amount match criteria * * @package Condition - * @author Guillaume MOREL + * @author Guillaume MOREL , Franck Allimant * */ class MatchForTotalAmount extends ConditionAbstract { /** Condition 1st parameter : price */ - CONST INPUT1 = 'price'; + CONST CART_TOTAL = 'price'; /** Condition 1st parameter : currency */ - CONST INPUT2 = 'currency'; + CONST CART_CURRENCY = 'currency'; - /** @var string Service Id from Resources/config.xml */ - protected $serviceId = 'thelia.condition.match_for_total_amount'; - - /** @var array Available Operators (Operators::CONST) */ - protected $availableOperators = array( - self::INPUT1 => array( - Operators::INFERIOR, - Operators::INFERIOR_OR_EQUAL, - Operators::EQUAL, - Operators::SUPERIOR_OR_EQUAL, - Operators::SUPERIOR - ), - self::INPUT2 => array( - Operators::EQUAL, - ) - ); - - /** - * Check validators relevancy and store them - * - * @param array $operators Operators the Admin set in BackOffice - * @param array $values Values the Admin set in BackOffice - * - * @throws \InvalidArgumentException - * @return $this - */ - public function setValidatorsFromForm(array $operators, array $values) + public function __construct(FacadeInterface $facade) { - $this->setValidators( - $operators[self::INPUT1], - $values[self::INPUT1], - $operators[self::INPUT2], - $values[self::INPUT2] - ); + // Define the allowed comparison operators + $this->availableOperators = [ + self::CART_TOTAL => [ + Operators::INFERIOR, + Operators::INFERIOR_OR_EQUAL, + Operators::EQUAL, + Operators::SUPERIOR_OR_EQUAL, + Operators::SUPERIOR + ], + self::CART_CURRENCY => [ + Operators::EQUAL, + ] + ]; - return $this; + parent::__construct($facade); } /** - * Check validators relevancy and store them - * - * @param string $priceOperator Price Operator ex < - * @param float $priceValue Price set to meet condition - * @param string $currencyOperator Currency Operator ex = - * @param string $currencyValue Currency set to meet condition - * - * @throws \Thelia\Exception\InvalidConditionOperatorException - * @return $this + * @inheritdoc */ - protected function setValidators($priceOperator, $priceValue, $currencyOperator, $currencyValue) + public function getServiceId() { - $isOperator1Legit = $this->isOperatorLegit( - $priceOperator, - $this->availableOperators[self::INPUT1] - ); - if (!$isOperator1Legit) { - throw new InvalidConditionOperatorException( - get_class(), 'price' - ); - } + return 'thelia.condition.match_for_total_amount'; + } - $isOperator1Legit = $this->isOperatorLegit( - $currencyOperator, - $this->availableOperators[self::INPUT2] - ); - if (!$isOperator1Legit) { - throw new InvalidConditionOperatorException( - get_class(), 'price' - ); - } + /** + * @inheritdoc + */ + public function setValidatorsFromForm(array $operators, array $values) + { + $this + ->checkComparisonOperatorValue($operators, self::CART_TOTAL) + ->checkComparisonOperatorValue($operators, self::CART_CURRENCY); - $this->isPriceValid($priceValue); + $this->isPriceValid($values[self::CART_TOTAL]); - $this->isCurrencyValid($currencyValue); + $this->isCurrencyValid($values[self::CART_CURRENCY]); $this->operators = array( - self::INPUT1 => $priceOperator, - self::INPUT2 => $currencyOperator, + self::CART_TOTAL => $operators[self::CART_TOTAL], + self::CART_CURRENCY => $operators[self::CART_CURRENCY], ); $this->values = array( - self::INPUT1 => $priceValue, - self::INPUT2 => $currencyValue, + self::CART_TOTAL => $values[self::CART_TOTAL], + self::CART_CURRENCY => $values[self::CART_CURRENCY], ); return $this; @@ -129,40 +94,39 @@ class MatchForTotalAmount extends ConditionAbstract { $condition1 = $this->conditionValidator->variableOpComparison( $this->facade->getCartTotalPrice(), - $this->operators[self::INPUT1], - $this->values[self::INPUT1] + $this->operators[self::CART_TOTAL], + $this->values[self::CART_TOTAL] ); - $condition2 = $this->conditionValidator->variableOpComparison( - $this->facade->getCheckoutCurrency(), - $this->operators[self::INPUT2], - $this->values[self::INPUT2] - ); - if ($condition1 && $condition2) { - return true; + + if ($condition1) { + $condition2 = $this->conditionValidator->variableOpComparison( + $this->facade->getCheckoutCurrency(), + $this->operators[self::CART_CURRENCY], + $this->values[self::CART_CURRENCY] + ); + + if ($condition2) { + return true; + } } return false; } /** - * Get I18n name - * - * @return string + * @inheritdoc */ public function getName() { return $this->translator->trans( - 'By cart total amount', + 'Cart total amount', [], 'condition' ); } /** - * Get I18n tooltip - * Explain in detail what the Condition checks - * - * @return string + * @inheritdoc */ public function getToolTip() { @@ -176,23 +140,21 @@ class MatchForTotalAmount extends ConditionAbstract } /** - * Get I18n summary - * Explain briefly the condition with given values - * - * @return string + * @inheritdoc */ public function getSummary() { $i18nOperator = Operators::getI18n( - $this->translator, $this->operators[self::INPUT1] + $this->translator, + $this->operators[self::CART_TOTAL] ); $toolTip = $this->translator->trans( 'If cart total amount is %operator% %amount% %currency%', array( '%operator%' => $i18nOperator, - '%amount%' => $this->values[self::INPUT1], - '%currency%' => $this->values[self::INPUT2] + '%amount%' => $this->values[self::CART_TOTAL], + '%currency%' => $this->values[self::CART_CURRENCY] ), 'condition' ); @@ -201,28 +163,28 @@ class MatchForTotalAmount extends ConditionAbstract } /** - * Generate inputs ready to be drawn - * - * @return array + * @inheritdoc */ protected function generateInputs() { $currencies = CurrencyQuery::create()->find(); + $cleanedCurrencies = []; + /** @var Currency $currency */ foreach ($currencies as $currency) { $cleanedCurrencies[$currency->getCode()] = $currency->getSymbol(); } return array( - self::INPUT1 => array( - 'availableOperators' => $this->availableOperators[self::INPUT1], + self::CART_TOTAL => array( + 'availableOperators' => $this->availableOperators[self::CART_TOTAL], 'availableValues' => '', 'value' => '', 'selectedOperator' => '' ), - self::INPUT2 => array( - 'availableOperators' => $this->availableOperators[self::INPUT2], + self::CART_CURRENCY => array( + 'availableOperators' => $this->availableOperators[self::CART_CURRENCY], 'availableValues' => $cleanedCurrencies, 'value' => '', 'selectedOperator' => Operators::EQUAL @@ -231,10 +193,7 @@ class MatchForTotalAmount extends ConditionAbstract } /** - * Draw the input displayed in the BackOffice - * allowing Admin to set its Coupon Conditions - * - * @return string HTML string + * @inheritdoc */ public function drawBackOfficeInputs() { @@ -242,32 +201,26 @@ class MatchForTotalAmount extends ConditionAbstract ->getTranslator() ->trans('Cart total amount is', [], 'condition'); - $html = $this->drawBackOfficeBaseInputsText($labelPrice, self::INPUT1); + $html = $this->drawBackOfficeBaseInputsText($labelPrice, self::CART_TOTAL); return $html; } /** - * Draw the base input displayed in the BackOffice - * allowing Admin to set its Coupon Conditions - * - * @param string $label I18n input label - * @param string $inputKey Input key (ex: self::INPUT1) - * - * @return string HTML string + * @inheritdoc */ protected function drawBackOfficeBaseInputsText($label, $inputKey) { - return $this->facade->getParser()->render('coupon/condition-fragments/cart-total-amount-condition.html', [ - 'label' => $label, - 'inputKey' => $inputKey, - 'value' => isset($this->values[$inputKey]) ? $this->values[$inputKey] : '', - - 'field_1_name' => self::INPUT1, - 'field_2_name' => self::INPUT2, - - 'operatorSelectHtml' => $this->drawBackOfficeInputOperators(self::INPUT1), - 'currencySelectHtml' => $this->drawBackOfficeCurrencyInput(self::INPUT2), + return $this->facade->getParser()->render( + 'coupon/condition-fragments/cart-total-amount-condition.html', + [ + 'label' => $label, + 'inputKey' => $inputKey, + 'value' => isset($this->values[$inputKey]) ? $this->values[$inputKey] : '', + 'field_1_name' => self::CART_TOTAL, + 'field_2_name' => self::CART_CURRENCY, + 'operatorSelectHtml' => $this->drawBackOfficeInputOperators(self::CART_TOTAL), + 'currencySelectHtml' => $this->drawBackOfficeCurrencyInput(self::CART_CURRENCY), ] ); } diff --git a/core/lib/Thelia/Condition/Implementation/MatchForXArticles.php b/core/lib/Thelia/Condition/Implementation/MatchForXArticles.php index 6e9b0d459..2f56abdb4 100644 --- a/core/lib/Thelia/Condition/Implementation/MatchForXArticles.php +++ b/core/lib/Thelia/Condition/Implementation/MatchForXArticles.php @@ -13,6 +13,7 @@ namespace Thelia\Condition\Implementation; use Thelia\Condition\Operators; +use Thelia\Coupon\FacadeInterface; use Thelia\Exception\InvalidConditionOperatorException; use Thelia\Exception\InvalidConditionValueException; @@ -20,96 +21,73 @@ use Thelia\Exception\InvalidConditionValueException; * Check a Checkout against its Product number * * @package Condition - * @author Guillaume MOREL + * @author Guillaume MOREL , Franck Allimant * */ class MatchForXArticles extends ConditionAbstract { /** Condition 1st parameter : quantity */ - CONST INPUT1 = 'quantity'; - - /** @var string Service Id from Resources/config.xml */ - protected $serviceId = 'thelia.condition.match_for_x_articles'; - - /** @var array Available Operators (Operators::CONST) */ - protected $availableOperators = array( - self::INPUT1 => array( - Operators::INFERIOR, - Operators::INFERIOR_OR_EQUAL, - Operators::EQUAL, - Operators::SUPERIOR_OR_EQUAL, - Operators::SUPERIOR - ) - ); + CONST CART_QUANTITY = 'quantity'; /** - * Check validators relevancy and store them - * - * @param array $operators Operators the Admin set in BackOffice - * @param array $values Values the Admin set in BackOffice - * - * @throws \InvalidArgumentException - * @return $this + * @inheritdoc */ - public function setValidatorsFromForm(array $operators, array $values) + public function __construct(FacadeInterface $facade) { - $this->setValidators( - $operators[self::INPUT1], - $values[self::INPUT1] + $this->availableOperators = array( + self::CART_QUANTITY => array( + Operators::INFERIOR, + Operators::INFERIOR_OR_EQUAL, + Operators::EQUAL, + Operators::SUPERIOR_OR_EQUAL, + Operators::SUPERIOR + ) ); - return $this; + parent::__construct($facade); } /** - * Check validators relevancy and store them - * - * @param string $quantityOperator Quantity Operator ex < - * @param int $quantityValue Quantity set to meet condition - * - * @throws \Thelia\Exception\InvalidConditionValueException - * @throws \Thelia\Exception\InvalidConditionOperatorException - * @return $this + * @inheritdoc */ - protected function setValidators($quantityOperator, $quantityValue) + public function getServiceId() { - $isOperator1Legit = $this->isOperatorLegit( - $quantityOperator, - $this->availableOperators[self::INPUT1] - ); - if (!$isOperator1Legit) { - throw new InvalidConditionOperatorException( - get_class(), 'quantity' - ); - } + return 'thelia.condition.match_for_x_articles'; + } - if ((int) $quantityValue <= 0) { + /** + * @inheritdoc + */ + public function setValidatorsFromForm(array $operators, array $values) + { + $this->checkComparisonOperatorValue($operators, self::CART_QUANTITY); + + if (intval($values[self::CART_QUANTITY]) <= 0) { throw new InvalidConditionValueException( get_class(), 'quantity' ); } - $this->operators = array( - self::INPUT1 => $quantityOperator, - ); - $this->values = array( - self::INPUT1 => $quantityValue, - ); + $this->operators = [ + self::CART_QUANTITY => $operators[self::CART_QUANTITY] + ]; + + $this->values = [ + self::CART_QUANTITY => $values[self::CART_QUANTITY] + ]; return $this; } /** - * Test if Customer meets conditions - * - * @return bool + * @inheritdoc */ public function isMatching() { $condition1 = $this->conditionValidator->variableOpComparison( $this->facade->getNbArticlesInCart(), - $this->operators[self::INPUT1], - $this->values[self::INPUT1] + $this->operators[self::CART_QUANTITY], + $this->values[self::CART_QUANTITY] ); if ($condition1) { @@ -120,24 +98,19 @@ class MatchForXArticles extends ConditionAbstract } /** - * Get I18n name - * - * @return string + * @inheritdoc */ public function getName() { return $this->translator->trans( - 'Cart item count condition', + 'Cart item count', [], 'condition' ); } /** - * Get I18n tooltip - * Explain in detail what the Condition checks - * - * @return string + * @inheritdoc */ public function getToolTip() { @@ -151,22 +124,19 @@ class MatchForXArticles extends ConditionAbstract } /** - * Get I18n summary - * Explain briefly the condition with given values - * - * @return string + * @inheritdoc */ public function getSummary() { $i18nOperator = Operators::getI18n( - $this->translator, $this->operators[self::INPUT1] + $this->translator, $this->operators[self::CART_QUANTITY] ); $toolTip = $this->translator->trans( 'If cart item count is %operator% %quantity%', array( '%operator%' => $i18nOperator, - '%quantity%' => $this->values[self::INPUT1] + '%quantity%' => $this->values[self::CART_QUANTITY] ), 'condition' ); @@ -175,15 +145,13 @@ class MatchForXArticles extends ConditionAbstract } /** - * Generate inputs ready to be drawn - * - * @return array + * @inheritdoc */ protected function generateInputs() { return array( - self::INPUT1 => array( - 'availableOperators' => $this->availableOperators[self::INPUT1], + self::CART_QUANTITY => array( + 'availableOperators' => $this->availableOperators[self::CART_QUANTITY], 'value' => '', 'selectedOperator' => '' ) @@ -191,10 +159,7 @@ class MatchForXArticles extends ConditionAbstract } /** - * Draw the input displayed in the BackOffice - * allowing Admin to set its Coupon Conditions - * - * @return string HTML string + * @inheritdoc */ public function drawBackOfficeInputs() { @@ -202,19 +167,13 @@ class MatchForXArticles extends ConditionAbstract ->getTranslator() ->trans('Cart item count is', [], 'condition'); - $html = $this->drawBackOfficeBaseInputsText($labelQuantity, self::INPUT1); + $html = $this->drawBackOfficeBaseInputsText($labelQuantity, self::CART_QUANTITY); return $html; } /** - * Draw the base input displayed in the BackOffice - * allowing Admin to set its Coupon Conditions - * - * @param string $label I18n input label - * @param string $inputKey Input key (ex: self::INPUT1) - * - * @return string HTML string + * @inheritdoc */ protected function drawBackOfficeBaseInputsText($label, $inputKey) { diff --git a/core/lib/Thelia/Condition/Implementation/StartDate.php b/core/lib/Thelia/Condition/Implementation/StartDate.php new file mode 100644 index 000000000..afcbb5814 --- /dev/null +++ b/core/lib/Thelia/Condition/Implementation/StartDate.php @@ -0,0 +1,192 @@ + + * + */ +class StartDate extends ConditionAbstract +{ + const START_DATE = 'start_date'; + + /** + * @inheritdoc + */ + public function __construct(FacadeInterface $facade) + { + $this->availableOperators = [ + self::START_DATE => [ + Operators::SUPERIOR_OR_EQUAL + ] + ]; + + parent::__construct($facade); + } + + /** + * @inheritdoc + */ + public function getServiceId() + { + return 'thelia.condition.start_date'; + } + + /** + * @inheritdoc + */ + public function setValidatorsFromForm(array $operators, array $values) + { + if (! isset($values[self::START_DATE])) { + $values[self::START_DATE] = time(); + } + + // Parse the entered date to get a timestamp, if we don't already have one + if (! is_int($values[self::START_DATE])) { + + $date = \DateTime::createFromFormat($this->getDateFormat(), $values[self::START_DATE]); + + // Check that the date is valid + if (false === $date) { + throw new InvalidConditionValueException( + get_class(), self::START_DATE + ); + } + + $timestamp = $date->getTimestamp(); + } + else { + $timestamp = $values[self::START_DATE]; + } + + $this->operators = [ self::START_DATE => $operators[self::START_DATE] ]; + $this->values = [ self::START_DATE => $timestamp ]; + + return $this; + } + + /** + * @inheritdoc + */ + public function isMatching() + { + return $this->conditionValidator->variableOpComparison( + time(), + $this->operators[self::START_DATE], + $this->values[self::START_DATE] + ); + } + + /** + * @inheritdoc + */ + public function getName() + { + return $this->translator->trans( + 'Start date', + [], + 'condition' + ); + } + + /** + * @inheritdoc + */ + public function getToolTip() + { + $toolTip = $this->translator->trans( + 'The coupon is valid after a given date', + [], + 'condition' + ); + + return $toolTip; + } + + /** + * @inheritdoc + */ + public function getSummary() + { + $i18nOperator = Operators::getI18n( + $this->translator, $this->operators[self::START_DATE] + ); + + $date = new \DateTime(); + $date->setTimestamp($this->values[self::START_DATE]); + $strDate = $date->format($this->getDateFormat()); + + $toolTip = $this->translator->trans( + 'Valid only from %date% to the coupon expiration date', [ + '%date%' => $strDate, + ], 'condition' + ); + + return $toolTip; + } + + private function getDateFormat() { + return DateTimeFormat::getInstance($this->facade->getRequest())->getFormat("date"); + } + + /** + * @inheritdoc + */ + protected function generateInputs() + { + return array( + self::START_DATE => array( + 'availableOperators' => $this->availableOperators[self::START_DATE], + 'value' => '', + 'selectedOperator' => Operators::SUPERIOR_OR_EQUAL + ) + ); + } + + /** + * @inheritdoc + */ + public function drawBackOfficeInputs() + { + if (isset($this->values[self::START_DATE])) { + + $date = new \DateTime(); + + $date->setTimestamp($this->values[self::START_DATE]); + + $strDate = $date->format($this->getDateFormat()); + } + else { + $strDate = ''; + } + + return $this->facade->getParser()->render('coupon/condition-fragments/start-date-condition.html', [ + 'fieldName' => self::START_DATE, + 'criteria' => Operators::SUPERIOR_OR_EQUAL, + 'dateFormat' => $this->getDateFormat(), + 'currentValue' => $strDate + ]); + } +} \ No newline at end of file diff --git a/core/lib/Thelia/Condition/Operators.php b/core/lib/Thelia/Condition/Operators.php index 58402719a..2daafdc3f 100644 --- a/core/lib/Thelia/Condition/Operators.php +++ b/core/lib/Thelia/Condition/Operators.php @@ -68,7 +68,7 @@ abstract class Operators break; case self::EQUAL: $ret = $translator->trans( - 'Equals', + 'Equal to', [], 'condition' ); @@ -89,7 +89,7 @@ abstract class Operators break; case self::DIFFERENT: $ret = $translator->trans( - 'Not equals', + 'Not equal to', [], 'condition' ); diff --git a/core/lib/Thelia/Config/I18n/en_US.php b/core/lib/Thelia/Config/I18n/en_US.php index 34f17dc22..17d6fcf75 100644 --- a/core/lib/Thelia/Config/I18n/en_US.php +++ b/core/lib/Thelia/Config/I18n/en_US.php @@ -34,6 +34,8 @@ return array( 'Available quantity *' => 'Available quantity *', 'Available shipping zones' => 'Available shipping zones', 'Bad tax list JSON' => 'Bad tax list JSON', + 'Billing country condition' => 'Pays de facturation', + 'Billing coutry is' => 'Le pays de facturation est', 'Business ID' => 'Business ID', 'By cart total amount' => 'By cart total amount', 'Cannot find a default country. Please define one.' => 'Cannot find a default country. Please define one.', @@ -68,6 +70,8 @@ return array( 'Default product sale element' => 'Default product sale element', 'Deleting document for %id% with parent id %parentId%' => 'Deleting document for %id% with parent id %parentId%', 'Deleting image for %id% with parent id %parentId%' => 'Deleting image for %id% with parent id %parentId%', + 'Delivery country condition' => 'Pays de livraison', + 'Delivery coutry is' => 'Le pays de livraison est', 'Delivery module ID not found' => 'Delivery module ID not found', 'Description' => 'Description', 'Detailed description' => 'Detailed description', @@ -81,7 +85,7 @@ return array( 'Emergency' => 'Emergency', 'Enable remote SMTP use' => 'Enable remote SMTP use', 'Encryption' => 'Encryption', - 'Equals' => 'Equals', + 'Equal to' => 'Egal à', 'Error during %action process : %error. Exception was %exc' => 'Error during %action process : %error. Exception was %exc', 'Error occured while processing order ref. %ref, ID %id: %err' => 'Error occured while processing order ref. %ref, ID %id: %err', 'Errors' => 'Errors', @@ -157,10 +161,12 @@ return array( 'No module found for code \'%item\'' => 'No module found for code \'%item\'', 'No pagination currently defined for loop name \'%name\'' => 'No pagination currently defined for loop name \'%name\'', 'No, I am a new customer.' => 'No, I am a new customer.', - 'Not equals' => 'Not equals', + 'Not equal to' => 'Différent de', 'Not found' => 'Not found', 'Not in' => 'Not in', 'Notices' => 'Notices', + 'Only if order billing country is %op% %countries_list%' => 'Le pays de facturation de la commande est %op% %countries_list% ', + 'Only if order shipping country is %op% %countries_list%' => 'Le pays de livraison de la commande est %op% %countries_list% ', 'Order address ID not found' => 'Order address ID not found', 'Order ref. %ref is now unpaid.' => 'Order ref. %ref is now unpaid.', 'Order ref. %ref, ID %id has been successfully paid.' => 'Order ref. %ref, ID %id has been successfully paid.', @@ -230,6 +236,7 @@ return array( 'Sorry, you are not allowed to perform this action.' => 'Sorry, you are not allowed to perform this action.', 'Sorry, you\'re not allowed to perform this action' => 'Sorry, you\'re not allowed to perform this action', 'Source IP' => 'Source IP', + 'Start date' => 'Date de début de validité', 'Stats on %month/%year' => 'Stats on %month/%year', 'Store configuration failed.' => 'Store configuration failed.', 'Store email address' => 'Store email address', @@ -253,6 +260,8 @@ return array( 'Text Message' => 'Text Message', 'The TaxEngine should be passed to this form before using it.' => 'The TaxEngine should be passed to this form before using it.', 'The cart item count should match the condition' => 'The cart item count should match the condition', + 'The coupon applies to the selected delivery countries' => 'Ce code promo s\'applique seulement aux pays de facturation sélectionnés', + 'The coupon is valid after a given date' => 'Le code promo est valide seulement à partir d\'une certaine date', 'The image which replaces an undefined country flag (%file) was not found. Please check unknown-flag-path configuration variable, and check that the image exists.' => 'The image which replaces an undefined country flag (%file) was not found. Please check unknown-flag-path configuration variable, and check that the image exists.', 'The loop name \'%name\' is already defined in %className class' => 'The loop name \'%name\' is already defined in %className class', 'This category is online.' => 'This category is online.', @@ -287,6 +296,7 @@ return array( 'Unsupported magic method %name. only getArgname() is supported.' => 'Unsupported magic method %name. only getArgname() is supported.', 'Username' => 'Username', 'Username *' => 'Username *', + 'Valid only from %date% to the coupon expiration date' => 'Valide à partir du %date% jusqu\'à la date d\'expiration', 'Value' => 'Value', 'Value *' => 'Value *', 'Warnings' => 'Warnings', @@ -299,6 +309,7 @@ return array( 'Your current password does not match.' => 'Your current password does not match.', 'Zip code' => 'Zip code', 'date format' => 'date format', + 'decimal separator' => 'Séparateur décimal', 'delivery module %s is not a Thelia\Module\DeliveryModuleInterface' => 'delivery module %s is not a Thelia\Module\DeliveryModuleInterface', 'language locale' => 'language locale', 'mailing system modification' => 'mailing system modification', @@ -308,5 +319,6 @@ return array( 'permanent discount (in percent)' => 'permanent discount (in percent)', 'quantity value is not valid' => 'quantity value is not valid', 'this product id does not exists : %d' => 'this product id does not exists : %d', + 'thousands separator' => 'Séparateur de milliers', 'time format' => 'time format', ); diff --git a/core/lib/Thelia/Config/Resources/coupon.xml b/core/lib/Thelia/Config/Resources/coupon.xml index d0d763ea2..68de33c37 100644 --- a/core/lib/Thelia/Config/Resources/coupon.xml +++ b/core/lib/Thelia/Config/Resources/coupon.xml @@ -33,23 +33,54 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/core/lib/Thelia/Core/Template/Smarty/Assets/SmartyAssetsManager.php b/core/lib/Thelia/Core/Template/Smarty/Assets/SmartyAssetsManager.php index 5974ef3db..e1d21d418 100644 --- a/core/lib/Thelia/Core/Template/Smarty/Assets/SmartyAssetsManager.php +++ b/core/lib/Thelia/Core/Template/Smarty/Assets/SmartyAssetsManager.php @@ -12,6 +12,7 @@ namespace Thelia\Core\Template\Smarty\Assets; +use Symfony\Component\Finder\Finder; use Thelia\Log\Tlog; use Thelia\Tools\URL; use Thelia\Core\Template\Assets\AssetManagerInterface; @@ -142,8 +143,14 @@ class SmartyAssetsManager } $url = ""; + // test if file exists before running the process - if (file_exists($assetSource . DS . $file)) { + $finder = new Finder(); + + $files = $finder->files()->in($assetSource)->name($file); + + if (! empty($files)) { + $url = $this->assetsManager->processAsset( $assetSource . DS . $file, $assetSource . DS . self::$assetsDirectory, @@ -156,6 +163,9 @@ class SmartyAssetsManager $debug ); } + else { + Tlog::getInstance()->addError("Asset $assetSource".DS."$file was not found."); + } return $url; } diff --git a/core/lib/Thelia/Coupon/BaseFacade.php b/core/lib/Thelia/Coupon/BaseFacade.php index bdc87261d..eac753376 100644 --- a/core/lib/Thelia/Coupon/BaseFacade.php +++ b/core/lib/Thelia/Coupon/BaseFacade.php @@ -20,6 +20,7 @@ use Thelia\Condition\ConditionEvaluator; use Thelia\Core\HttpFoundation\Request; use Thelia\Core\Template\ParserInterface; use Thelia\Core\Template\TemplateHelper; +use Thelia\Model\AddressQuery; use Thelia\Model\Coupon; use Thelia\Model\CouponQuery; use Thelia\Cart\CartTrait; @@ -75,7 +76,12 @@ class BaseFacade implements FacadeInterface */ public function getDeliveryAddress() { - // @todo: Implement getDeliveryAddress() method. + try { + return AddressQuery::create()->findPk($this->getRequest()->getSession()->getOrder()->chosenDeliveryAddress); + } + catch(\Exception $ex) { + throw new \LogicException("Failed to get delivery address (" . $ex->getMessage() . ")"); + } } /** diff --git a/core/lib/Thelia/Coupon/CouponManager.php b/core/lib/Thelia/Coupon/CouponManager.php index daf1ca9d2..779b28c11 100644 --- a/core/lib/Thelia/Coupon/CouponManager.php +++ b/core/lib/Thelia/Coupon/CouponManager.php @@ -111,7 +111,7 @@ class CouponManager /** @var CouponInterface $coupon */ foreach ($coupons as $coupon) { - if (!$coupon->isExpired()) { + if ($coupon && !$coupon->isExpired()) { if ($coupon->isCumulative()) { if (isset($couponsKept[0])) { /** @var CouponInterface $previousCoupon */ diff --git a/core/lib/Thelia/Tests/Condition/ConditionCollectionTest.php b/core/lib/Thelia/Tests/Condition/ConditionCollectionTest.php index 679f22791..ee01d5003 100644 --- a/core/lib/Thelia/Tests/Condition/ConditionCollectionTest.php +++ b/core/lib/Thelia/Tests/Condition/ConditionCollectionTest.php @@ -101,12 +101,12 @@ class ConditionCollectionTest extends \PHPUnit_Framework_TestCase $condition1 = new MatchForTotalAmount($stubFacade); $operators = array( - MatchForTotalAmount::INPUT1 => Operators::EQUAL, - MatchForTotalAmount::INPUT2 => Operators::EQUAL + MatchForTotalAmount::CART_TOTAL => Operators::EQUAL, + MatchForTotalAmount::CART_CURRENCY => Operators::EQUAL ); $values = array( - MatchForTotalAmount::INPUT1 => 400, - MatchForTotalAmount::INPUT2 => 'EUR'); + MatchForTotalAmount::CART_TOTAL => 400, + MatchForTotalAmount::CART_CURRENCY => 'EUR'); $condition1->setValidatorsFromForm($operators, $values); $collection = new ConditionCollection(); @@ -138,22 +138,22 @@ class ConditionCollectionTest extends \PHPUnit_Framework_TestCase $condition1 = new MatchForTotalAmount($stubFacade); $operators1 = array( - MatchForTotalAmount::INPUT1 => Operators::SUPERIOR, - MatchForTotalAmount::INPUT2 => Operators::EQUAL + MatchForTotalAmount::CART_TOTAL => Operators::SUPERIOR, + MatchForTotalAmount::CART_CURRENCY => Operators::EQUAL ); $values1 = array( - MatchForTotalAmount::INPUT1 => 400, - MatchForTotalAmount::INPUT2 => 'EUR'); + MatchForTotalAmount::CART_TOTAL => 400, + MatchForTotalAmount::CART_CURRENCY => 'EUR'); $condition1->setValidatorsFromForm($operators1, $values1); $condition2 = new MatchForTotalAmount($stubFacade); $operators2 = array( - MatchForTotalAmount::INPUT1 => Operators::INFERIOR, - MatchForTotalAmount::INPUT2 => Operators::EQUAL + MatchForTotalAmount::CART_TOTAL => Operators::INFERIOR, + MatchForTotalAmount::CART_CURRENCY => Operators::EQUAL ); $values2 = array( - MatchForTotalAmount::INPUT1 => 600, - MatchForTotalAmount::INPUT2 => 'EUR'); + MatchForTotalAmount::CART_TOTAL => 600, + MatchForTotalAmount::CART_CURRENCY => 'EUR'); $condition2->setValidatorsFromForm($operators2, $values2); $collection = new ConditionCollection(); diff --git a/core/lib/Thelia/Tests/Condition/ConditionFactoryTest.php b/core/lib/Thelia/Tests/Condition/ConditionFactoryTest.php index 854803411..2ea9ffe1d 100644 --- a/core/lib/Thelia/Tests/Condition/ConditionFactoryTest.php +++ b/core/lib/Thelia/Tests/Condition/ConditionFactoryTest.php @@ -81,12 +81,12 @@ class ConditionFactoryTest extends \PHPUnit_Framework_TestCase $condition1 = new MatchForTotalAmount($stubFacade); $operators = array( - MatchForTotalAmount::INPUT1 => Operators::SUPERIOR, - MatchForTotalAmount::INPUT2 => Operators::EQUAL + MatchForTotalAmount::CART_TOTAL => Operators::SUPERIOR, + MatchForTotalAmount::CART_CURRENCY => Operators::EQUAL ); $values = array( - MatchForTotalAmount::INPUT1 => 40.00, - MatchForTotalAmount::INPUT2 => 'EUR' + MatchForTotalAmount::CART_TOTAL => 40.00, + MatchForTotalAmount::CART_CURRENCY => 'EUR' ); $condition1->setValidatorsFromForm($operators, $values); @@ -145,12 +145,12 @@ class ConditionFactoryTest extends \PHPUnit_Framework_TestCase $condition1 = new MatchForTotalAmount($stubFacade); $operators = array( - MatchForTotalAmount::INPUT1 => Operators::SUPERIOR, - MatchForTotalAmount::INPUT2 => Operators::EQUAL + MatchForTotalAmount::CART_TOTAL => Operators::SUPERIOR, + MatchForTotalAmount::CART_CURRENCY => Operators::EQUAL ); $values = array( - MatchForTotalAmount::INPUT1 => 40.00, - MatchForTotalAmount::INPUT2 => 'EUR' + MatchForTotalAmount::CART_TOTAL => 40.00, + MatchForTotalAmount::CART_CURRENCY => 'EUR' ); $condition1->setValidatorsFromForm($operators, $values); @@ -207,23 +207,23 @@ class ConditionFactoryTest extends \PHPUnit_Framework_TestCase $condition1 = new MatchForTotalAmount($stubFacade); $operators = array( - MatchForTotalAmount::INPUT1 => Operators::SUPERIOR, - MatchForTotalAmount::INPUT2 => Operators::EQUAL + MatchForTotalAmount::CART_TOTAL => Operators::SUPERIOR, + MatchForTotalAmount::CART_CURRENCY => Operators::EQUAL ); $values = array( - MatchForTotalAmount::INPUT1 => 40.00, - MatchForTotalAmount::INPUT2 => 'EUR' + MatchForTotalAmount::CART_TOTAL => 40.00, + MatchForTotalAmount::CART_CURRENCY => 'EUR' ); $condition1->setValidatorsFromForm($operators, $values); $condition2 = new MatchForTotalAmount($stubFacade); $operators = array( - MatchForTotalAmount::INPUT1 => Operators::SUPERIOR, - MatchForTotalAmount::INPUT2 => Operators::EQUAL + MatchForTotalAmount::CART_TOTAL => Operators::SUPERIOR, + MatchForTotalAmount::CART_CURRENCY => Operators::EQUAL ); $values = array( - MatchForTotalAmount::INPUT1 => 400.00, - MatchForTotalAmount::INPUT2 => 'EUR' + MatchForTotalAmount::CART_TOTAL => 400.00, + MatchForTotalAmount::CART_CURRENCY => 'EUR' ); $condition2->setValidatorsFromForm($operators, $values); @@ -286,12 +286,12 @@ class ConditionFactoryTest extends \PHPUnit_Framework_TestCase ->will($this->returnValue($stubContainer)); $operators = array( - MatchForTotalAmount::INPUT1 => Operators::SUPERIOR, - MatchForTotalAmount::INPUT2 => Operators::EQUAL + MatchForTotalAmount::CART_TOTAL => Operators::SUPERIOR, + MatchForTotalAmount::CART_CURRENCY => Operators::EQUAL ); $values = array( - MatchForTotalAmount::INPUT1 => 40.00, - MatchForTotalAmount::INPUT2 => 'EUR' + MatchForTotalAmount::CART_TOTAL => 40.00, + MatchForTotalAmount::CART_CURRENCY => 'EUR' ); $condition1->setValidatorsFromForm($operators, $values); @@ -351,12 +351,12 @@ class ConditionFactoryTest extends \PHPUnit_Framework_TestCase ->will($this->returnValue($stubContainer)); $operators = array( - MatchForTotalAmount::INPUT1 => Operators::SUPERIOR, - MatchForTotalAmount::INPUT2 => Operators::EQUAL + MatchForTotalAmount::CART_TOTAL => Operators::SUPERIOR, + MatchForTotalAmount::CART_CURRENCY => Operators::EQUAL ); $values = array( - MatchForTotalAmount::INPUT1 => 40.00, - MatchForTotalAmount::INPUT2 => 'EUR' + MatchForTotalAmount::CART_TOTAL => 40.00, + MatchForTotalAmount::CART_CURRENCY => 'EUR' ); $condition1->setValidatorsFromForm($operators, $values); diff --git a/core/lib/Thelia/Tests/Condition/Implementation/MatchForTotalAmountTest.php b/core/lib/Thelia/Tests/Condition/Implementation/MatchForTotalAmountTest.php index 102132196..bffbda092 100644 --- a/core/lib/Thelia/Tests/Condition/Implementation/MatchForTotalAmountTest.php +++ b/core/lib/Thelia/Tests/Condition/Implementation/MatchForTotalAmountTest.php @@ -94,12 +94,12 @@ class MatchForTotalAmountTest extends \PHPUnit_Framework_TestCase /** @var FacadeInterface $stubFacade */ $condition1 = new MatchForTotalAmount($stubFacade); $operators = array( - MatchForTotalAmount::INPUT1 => Operators::IN, - MatchForTotalAmount::INPUT2 => Operators::EQUAL + MatchForTotalAmount::CART_TOTAL => Operators::IN, + MatchForTotalAmount::CART_CURRENCY => Operators::EQUAL ); $values = array( - MatchForTotalAmount::INPUT1 => '400', - MatchForTotalAmount::INPUT2 => 'EUR'); + MatchForTotalAmount::CART_TOTAL => '400', + MatchForTotalAmount::CART_CURRENCY => 'EUR'); $condition1->setValidatorsFromForm($operators, $values); $isValid = $condition1->isMatching(); @@ -123,12 +123,12 @@ class MatchForTotalAmountTest extends \PHPUnit_Framework_TestCase /** @var FacadeInterface $stubFacade */ $condition1 = new MatchForTotalAmount($stubFacade); $operators = array( - MatchForTotalAmount::INPUT1 => Operators::SUPERIOR, - MatchForTotalAmount::INPUT2 => Operators::INFERIOR + MatchForTotalAmount::CART_TOTAL => Operators::SUPERIOR, + MatchForTotalAmount::CART_CURRENCY => Operators::INFERIOR ); $values = array( - MatchForTotalAmount::INPUT1 => '400', - MatchForTotalAmount::INPUT2 => 'EUR'); + MatchForTotalAmount::CART_TOTAL => '400', + MatchForTotalAmount::CART_CURRENCY => 'EUR'); $condition1->setValidatorsFromForm($operators, $values); $isValid = $condition1->isMatching(); @@ -152,12 +152,12 @@ class MatchForTotalAmountTest extends \PHPUnit_Framework_TestCase $condition1 = new MatchForTotalAmount($stubFacade); $operators = array( - MatchForTotalAmount::INPUT1 => Operators::SUPERIOR, - MatchForTotalAmount::INPUT2 => Operators::EQUAL + MatchForTotalAmount::CART_TOTAL => Operators::SUPERIOR, + MatchForTotalAmount::CART_CURRENCY => Operators::EQUAL ); $values = array( - MatchForTotalAmount::INPUT1 => 'X', - MatchForTotalAmount::INPUT2 => 'EUR'); + MatchForTotalAmount::CART_TOTAL => 'X', + MatchForTotalAmount::CART_CURRENCY => 'EUR'); $condition1->setValidatorsFromForm($operators, $values); $isValid = $condition1->isMatching(); @@ -181,12 +181,12 @@ class MatchForTotalAmountTest extends \PHPUnit_Framework_TestCase $condition1 = new MatchForTotalAmount($stubFacade); $operators = array( - MatchForTotalAmount::INPUT1 => Operators::SUPERIOR, - MatchForTotalAmount::INPUT2 => Operators::EQUAL + MatchForTotalAmount::CART_TOTAL => Operators::SUPERIOR, + MatchForTotalAmount::CART_CURRENCY => Operators::EQUAL ); $values = array( - MatchForTotalAmount::INPUT1 => 400, - MatchForTotalAmount::INPUT2 => 'FLA'); + MatchForTotalAmount::CART_TOTAL => 400, + MatchForTotalAmount::CART_CURRENCY => 'FLA'); $condition1->setValidatorsFromForm($operators, $values); $isValid = $condition1->isMatching(); @@ -209,12 +209,12 @@ class MatchForTotalAmountTest extends \PHPUnit_Framework_TestCase $condition1 = new MatchForTotalAmount($stubFacade); $operators = array( - MatchForTotalAmount::INPUT1 => Operators::INFERIOR, - MatchForTotalAmount::INPUT2 => Operators::EQUAL + MatchForTotalAmount::CART_TOTAL => Operators::INFERIOR, + MatchForTotalAmount::CART_CURRENCY => Operators::EQUAL ); $values = array( - MatchForTotalAmount::INPUT1 => 400.00, - MatchForTotalAmount::INPUT2 => 'EUR'); + MatchForTotalAmount::CART_TOTAL => 400.00, + MatchForTotalAmount::CART_CURRENCY => 'EUR'); $condition1->setValidatorsFromForm($operators, $values); $isValid = $condition1->isMatching(); @@ -237,12 +237,12 @@ class MatchForTotalAmountTest extends \PHPUnit_Framework_TestCase $condition1 = new MatchForTotalAmount($stubFacade); $operators = array( - MatchForTotalAmount::INPUT1 => Operators::INFERIOR, - MatchForTotalAmount::INPUT2 => Operators::EQUAL + MatchForTotalAmount::CART_TOTAL => Operators::INFERIOR, + MatchForTotalAmount::CART_CURRENCY => Operators::EQUAL ); $values = array( - MatchForTotalAmount::INPUT1 => 400.00, - MatchForTotalAmount::INPUT2 => 'EUR'); + MatchForTotalAmount::CART_TOTAL => 400.00, + MatchForTotalAmount::CART_CURRENCY => 'EUR'); $condition1->setValidatorsFromForm($operators, $values); $isValid = $condition1->isMatching(); @@ -265,12 +265,12 @@ class MatchForTotalAmountTest extends \PHPUnit_Framework_TestCase $condition1 = new MatchForTotalAmount($stubFacade); $operators = array( - MatchForTotalAmount::INPUT1 => Operators::INFERIOR_OR_EQUAL, - MatchForTotalAmount::INPUT2 => Operators::EQUAL + MatchForTotalAmount::CART_TOTAL => Operators::INFERIOR_OR_EQUAL, + MatchForTotalAmount::CART_CURRENCY => Operators::EQUAL ); $values = array( - MatchForTotalAmount::INPUT1 => 400.00, - MatchForTotalAmount::INPUT2 => 'EUR'); + MatchForTotalAmount::CART_TOTAL => 400.00, + MatchForTotalAmount::CART_CURRENCY => 'EUR'); $condition1->setValidatorsFromForm($operators, $values); $isValid = $condition1->isMatching(); @@ -293,12 +293,12 @@ class MatchForTotalAmountTest extends \PHPUnit_Framework_TestCase $condition1 = new MatchForTotalAmount($stubFacade); $operators = array( - MatchForTotalAmount::INPUT1 => Operators::INFERIOR_OR_EQUAL, - MatchForTotalAmount::INPUT2 => Operators::EQUAL + MatchForTotalAmount::CART_TOTAL => Operators::INFERIOR_OR_EQUAL, + MatchForTotalAmount::CART_CURRENCY => Operators::EQUAL ); $values = array( - MatchForTotalAmount::INPUT1 => 400.00, - MatchForTotalAmount::INPUT2 => 'EUR'); + MatchForTotalAmount::CART_TOTAL => 400.00, + MatchForTotalAmount::CART_CURRENCY => 'EUR'); $condition1->setValidatorsFromForm($operators, $values); $isValid = $condition1->isMatching(); @@ -321,12 +321,12 @@ class MatchForTotalAmountTest extends \PHPUnit_Framework_TestCase $condition1 = new MatchForTotalAmount($stubFacade); $operators = array( - MatchForTotalAmount::INPUT1 => Operators::INFERIOR_OR_EQUAL, - MatchForTotalAmount::INPUT2 => Operators::EQUAL + MatchForTotalAmount::CART_TOTAL => Operators::INFERIOR_OR_EQUAL, + MatchForTotalAmount::CART_CURRENCY => Operators::EQUAL ); $values = array( - MatchForTotalAmount::INPUT1 => 400.00, - MatchForTotalAmount::INPUT2 => 'EUR'); + MatchForTotalAmount::CART_TOTAL => 400.00, + MatchForTotalAmount::CART_CURRENCY => 'EUR'); $condition1->setValidatorsFromForm($operators, $values); $isValid = $condition1->isMatching(); @@ -349,12 +349,12 @@ class MatchForTotalAmountTest extends \PHPUnit_Framework_TestCase $condition1 = new MatchForTotalAmount($stubFacade); $operators = array( - MatchForTotalAmount::INPUT1 => Operators::EQUAL, - MatchForTotalAmount::INPUT2 => Operators::EQUAL + MatchForTotalAmount::CART_TOTAL => Operators::EQUAL, + MatchForTotalAmount::CART_CURRENCY => Operators::EQUAL ); $values = array( - MatchForTotalAmount::INPUT1 => 400.00, - MatchForTotalAmount::INPUT2 => 'EUR'); + MatchForTotalAmount::CART_TOTAL => 400.00, + MatchForTotalAmount::CART_CURRENCY => 'EUR'); $condition1->setValidatorsFromForm($operators, $values); $isValid = $condition1->isMatching(); @@ -377,12 +377,12 @@ class MatchForTotalAmountTest extends \PHPUnit_Framework_TestCase $condition1 = new MatchForTotalAmount($stubFacade); $operators = array( - MatchForTotalAmount::INPUT1 => Operators::EQUAL, - MatchForTotalAmount::INPUT2 => Operators::EQUAL + MatchForTotalAmount::CART_TOTAL => Operators::EQUAL, + MatchForTotalAmount::CART_CURRENCY => Operators::EQUAL ); $values = array( - MatchForTotalAmount::INPUT1 => 400.00, - MatchForTotalAmount::INPUT2 => 'EUR'); + MatchForTotalAmount::CART_TOTAL => 400.00, + MatchForTotalAmount::CART_CURRENCY => 'EUR'); $condition1->setValidatorsFromForm($operators, $values); $isValid = $condition1->isMatching(); @@ -405,12 +405,12 @@ class MatchForTotalAmountTest extends \PHPUnit_Framework_TestCase $condition1 = new MatchForTotalAmount($stubFacade); $operators = array( - MatchForTotalAmount::INPUT1 => Operators::SUPERIOR_OR_EQUAL, - MatchForTotalAmount::INPUT2 => Operators::EQUAL + MatchForTotalAmount::CART_TOTAL => Operators::SUPERIOR_OR_EQUAL, + MatchForTotalAmount::CART_CURRENCY => Operators::EQUAL ); $values = array( - MatchForTotalAmount::INPUT1 => 400.00, - MatchForTotalAmount::INPUT2 => 'EUR'); + MatchForTotalAmount::CART_TOTAL => 400.00, + MatchForTotalAmount::CART_CURRENCY => 'EUR'); $condition1->setValidatorsFromForm($operators, $values); $isValid = $condition1->isMatching(); @@ -433,12 +433,12 @@ class MatchForTotalAmountTest extends \PHPUnit_Framework_TestCase $condition1 = new MatchForTotalAmount($stubFacade); $operators = array( - MatchForTotalAmount::INPUT1 => Operators::SUPERIOR_OR_EQUAL, - MatchForTotalAmount::INPUT2 => Operators::EQUAL + MatchForTotalAmount::CART_TOTAL => Operators::SUPERIOR_OR_EQUAL, + MatchForTotalAmount::CART_CURRENCY => Operators::EQUAL ); $values = array( - MatchForTotalAmount::INPUT1 => 400.00, - MatchForTotalAmount::INPUT2 => 'EUR'); + MatchForTotalAmount::CART_TOTAL => 400.00, + MatchForTotalAmount::CART_CURRENCY => 'EUR'); $condition1->setValidatorsFromForm($operators, $values); $isValid = $condition1->isMatching(); @@ -461,12 +461,12 @@ class MatchForTotalAmountTest extends \PHPUnit_Framework_TestCase $condition1 = new MatchForTotalAmount($stubFacade); $operators = array( - MatchForTotalAmount::INPUT1 => Operators::SUPERIOR_OR_EQUAL, - MatchForTotalAmount::INPUT2 => Operators::EQUAL + MatchForTotalAmount::CART_TOTAL => Operators::SUPERIOR_OR_EQUAL, + MatchForTotalAmount::CART_CURRENCY => Operators::EQUAL ); $values = array( - MatchForTotalAmount::INPUT1 => 400.00, - MatchForTotalAmount::INPUT2 => 'EUR'); + MatchForTotalAmount::CART_TOTAL => 400.00, + MatchForTotalAmount::CART_CURRENCY => 'EUR'); $condition1->setValidatorsFromForm($operators, $values); $isValid = $condition1->isMatching(); @@ -489,12 +489,12 @@ class MatchForTotalAmountTest extends \PHPUnit_Framework_TestCase $condition1 = new MatchForTotalAmount($stubFacade); $operators = array( - MatchForTotalAmount::INPUT1 => Operators::SUPERIOR, - MatchForTotalAmount::INPUT2 => Operators::EQUAL + MatchForTotalAmount::CART_TOTAL => Operators::SUPERIOR, + MatchForTotalAmount::CART_CURRENCY => Operators::EQUAL ); $values = array( - MatchForTotalAmount::INPUT1 => 400.00, - MatchForTotalAmount::INPUT2 => 'EUR'); + MatchForTotalAmount::CART_TOTAL => 400.00, + MatchForTotalAmount::CART_CURRENCY => 'EUR'); $condition1->setValidatorsFromForm($operators, $values); $isValid = $condition1->isMatching(); @@ -517,12 +517,12 @@ class MatchForTotalAmountTest extends \PHPUnit_Framework_TestCase $condition1 = new MatchForTotalAmount($stubFacade); $operators = array( - MatchForTotalAmount::INPUT1 => Operators::SUPERIOR, - MatchForTotalAmount::INPUT2 => Operators::EQUAL + MatchForTotalAmount::CART_TOTAL => Operators::SUPERIOR, + MatchForTotalAmount::CART_CURRENCY => Operators::EQUAL ); $values = array( - MatchForTotalAmount::INPUT1 => 400.00, - MatchForTotalAmount::INPUT2 => 'EUR'); + MatchForTotalAmount::CART_TOTAL => 400.00, + MatchForTotalAmount::CART_CURRENCY => 'EUR'); $condition1->setValidatorsFromForm($operators, $values); $isValid = $condition1->isMatching(); @@ -545,12 +545,12 @@ class MatchForTotalAmountTest extends \PHPUnit_Framework_TestCase $condition1 = new MatchForTotalAmount($stubFacade); $operators = array( - MatchForTotalAmount::INPUT1 => Operators::EQUAL, - MatchForTotalAmount::INPUT2 => Operators::EQUAL + MatchForTotalAmount::CART_TOTAL => Operators::EQUAL, + MatchForTotalAmount::CART_CURRENCY => Operators::EQUAL ); $values = array( - MatchForTotalAmount::INPUT1 => 400.00, - MatchForTotalAmount::INPUT2 => 'EUR'); + MatchForTotalAmount::CART_TOTAL => 400.00, + MatchForTotalAmount::CART_CURRENCY => 'EUR'); $condition1->setValidatorsFromForm($operators, $values); $isValid = $condition1->isMatching(); @@ -573,12 +573,12 @@ class MatchForTotalAmountTest extends \PHPUnit_Framework_TestCase $condition1 = new MatchForTotalAmount($stubFacade); $operators = array( - MatchForTotalAmount::INPUT1 => Operators::EQUAL, - MatchForTotalAmount::INPUT2 => Operators::EQUAL + MatchForTotalAmount::CART_TOTAL => Operators::EQUAL, + MatchForTotalAmount::CART_CURRENCY => Operators::EQUAL ); $values = array( - MatchForTotalAmount::INPUT1 => 400.00, - MatchForTotalAmount::INPUT2 => 'USD'); + MatchForTotalAmount::CART_TOTAL => 400.00, + MatchForTotalAmount::CART_CURRENCY => 'USD'); $condition1->setValidatorsFromForm($operators, $values); $isValid = $condition1->isMatching(); @@ -621,12 +621,12 @@ class MatchForTotalAmountTest extends \PHPUnit_Framework_TestCase $condition1 = new MatchForTotalAmount($stubFacade); $operators = array( - MatchForTotalAmount::INPUT1 => Operators::EQUAL, - MatchForTotalAmount::INPUT2 => Operators::EQUAL + MatchForTotalAmount::CART_TOTAL => Operators::EQUAL, + MatchForTotalAmount::CART_CURRENCY => Operators::EQUAL ); $values = array( - MatchForTotalAmount::INPUT1 => 400.00, - MatchForTotalAmount::INPUT2 => 'UNK'); + MatchForTotalAmount::CART_TOTAL => 400.00, + MatchForTotalAmount::CART_CURRENCY => 'UNK'); $condition1->setValidatorsFromForm($operators, $values); $stubContainer = $this->getMockBuilder('\Symfony\Component\DependencyInjection\Container') @@ -686,12 +686,12 @@ class MatchForTotalAmountTest extends \PHPUnit_Framework_TestCase $condition1 = new MatchForTotalAmount($stubFacade); $operators = array( - MatchForTotalAmount::INPUT1 => Operators::EQUAL, - MatchForTotalAmount::INPUT2 => Operators::EQUAL + MatchForTotalAmount::CART_TOTAL => Operators::EQUAL, + MatchForTotalAmount::CART_CURRENCY => Operators::EQUAL ); $values = array( - MatchForTotalAmount::INPUT1 => 'notfloat', - MatchForTotalAmount::INPUT2 => 'EUR'); + MatchForTotalAmount::CART_TOTAL => 'notfloat', + MatchForTotalAmount::CART_CURRENCY => 'EUR'); $condition1->setValidatorsFromForm($operators, $values); $stubContainer = $this->getMockBuilder('\Symfony\Component\DependencyInjection\Container') @@ -751,12 +751,12 @@ class MatchForTotalAmountTest extends \PHPUnit_Framework_TestCase $condition1 = new MatchForTotalAmount($stubFacade); $operators = array( - MatchForTotalAmount::INPUT1 => Operators::EQUAL, - MatchForTotalAmount::INPUT2 => Operators::EQUAL + MatchForTotalAmount::CART_TOTAL => Operators::EQUAL, + MatchForTotalAmount::CART_CURRENCY => Operators::EQUAL ); $values = array( - MatchForTotalAmount::INPUT1 => 0.00, - MatchForTotalAmount::INPUT2 => 'EUR'); + MatchForTotalAmount::CART_TOTAL => 0.00, + MatchForTotalAmount::CART_CURRENCY => 'EUR'); $condition1->setValidatorsFromForm($operators, $values); $stubContainer = $this->getMockBuilder('\Symfony\Component\DependencyInjection\Container') @@ -863,12 +863,12 @@ class MatchForTotalAmountTest extends \PHPUnit_Framework_TestCase /** @var FacadeInterface $stubFacade */ $condition1 = new MatchForTotalAmount($stubFacade); $operators = array( - MatchForTotalAmount::INPUT1 => Operators::EQUAL, - MatchForTotalAmount::INPUT2 => Operators::EQUAL + MatchForTotalAmount::CART_TOTAL => Operators::EQUAL, + MatchForTotalAmount::CART_CURRENCY => Operators::EQUAL ); $values = array( - MatchForTotalAmount::INPUT1 => 400.00, - MatchForTotalAmount::INPUT2 => 'EUR'); + MatchForTotalAmount::CART_TOTAL => 400.00, + MatchForTotalAmount::CART_CURRENCY => 'EUR'); $condition1->setValidatorsFromForm($operators, $values); $actual = $condition1->getToolTip(); @@ -889,19 +889,19 @@ class MatchForTotalAmountTest extends \PHPUnit_Framework_TestCase /** @var FacadeInterface $stubFacade */ $condition1 = new MatchForTotalAmount($stubFacade); $operators = array( - MatchForTotalAmount::INPUT1 => Operators::EQUAL, - MatchForTotalAmount::INPUT2 => Operators::EQUAL + MatchForTotalAmount::CART_TOTAL => Operators::EQUAL, + MatchForTotalAmount::CART_CURRENCY => Operators::EQUAL ); $values = array( - MatchForTotalAmount::INPUT1 => 400.00, - MatchForTotalAmount::INPUT2 => 'EUR'); + MatchForTotalAmount::CART_TOTAL => 400.00, + MatchForTotalAmount::CART_CURRENCY => 'EUR'); $condition1->setValidatorsFromForm($operators, $values); $actual = $condition1->getValidators(); $validators = array( 'inputs' => array( - MatchForTotalAmount::INPUT1 => array( + MatchForTotalAmount::CART_TOTAL => array( 'availableOperators' => array( '<' => 'Price', '<=' => 'Price', @@ -913,7 +913,7 @@ class MatchForTotalAmountTest extends \PHPUnit_Framework_TestCase 'value' => '', 'selectedOperator' => '' ), - MatchForTotalAmount::INPUT2 => array( + MatchForTotalAmount::CART_CURRENCY => array( 'availableOperators' => array('==' => 'Price'), 'availableValues' => array( 'EUR' => '€', diff --git a/core/lib/Thelia/Tests/Condition/Implementation/MatchForXArticlesTest.php b/core/lib/Thelia/Tests/Condition/Implementation/MatchForXArticlesTest.php index 3d96df4a2..c00f7a6ce 100644 --- a/core/lib/Thelia/Tests/Condition/Implementation/MatchForXArticlesTest.php +++ b/core/lib/Thelia/Tests/Condition/Implementation/MatchForXArticlesTest.php @@ -59,10 +59,10 @@ class MatchForXArticlesTest extends \PHPUnit_Framework_TestCase $condition1 = new MatchForXArticles($stubFacade); $operators = array( - MatchForXArticles::INPUT1 => Operators::IN + MatchForXArticles::CART_QUANTITY => Operators::IN ); $values = array( - MatchForXArticles::INPUT1 => 5 + MatchForXArticles::CART_QUANTITY => 5 ); $condition1->setValidatorsFromForm($operators, $values); @@ -95,10 +95,10 @@ class MatchForXArticlesTest extends \PHPUnit_Framework_TestCase $condition1 = new MatchForXArticles($stubFacade); $operators = array( - MatchForXArticles::INPUT1 => Operators::SUPERIOR + MatchForXArticles::CART_QUANTITY => Operators::SUPERIOR ); $values = array( - MatchForXArticles::INPUT1 => 'X' + MatchForXArticles::CART_QUANTITY => 'X' ); $condition1->setValidatorsFromForm($operators, $values); @@ -131,10 +131,10 @@ class MatchForXArticlesTest extends \PHPUnit_Framework_TestCase $condition1 = new MatchForXArticles($stubFacade); $operators = array( - MatchForXArticles::INPUT1 => Operators::INFERIOR + MatchForXArticles::CART_QUANTITY => Operators::INFERIOR ); $values = array( - MatchForXArticles::INPUT1 => 5 + MatchForXArticles::CART_QUANTITY => 5 ); $condition1->setValidatorsFromForm($operators, $values); @@ -167,10 +167,10 @@ class MatchForXArticlesTest extends \PHPUnit_Framework_TestCase $condition1 = new MatchForXArticles($stubFacade); $operators = array( - MatchForXArticles::INPUT1 => Operators::INFERIOR + MatchForXArticles::CART_QUANTITY => Operators::INFERIOR ); $values = array( - MatchForXArticles::INPUT1 => 4, + MatchForXArticles::CART_QUANTITY => 4, ); $condition1->setValidatorsFromForm($operators, $values); @@ -203,10 +203,10 @@ class MatchForXArticlesTest extends \PHPUnit_Framework_TestCase $condition1 = new MatchForXArticles($stubFacade); $operators = array( - MatchForXArticles::INPUT1 => Operators::INFERIOR_OR_EQUAL, + MatchForXArticles::CART_QUANTITY => Operators::INFERIOR_OR_EQUAL, ); $values = array( - MatchForXArticles::INPUT1 => 5, + MatchForXArticles::CART_QUANTITY => 5, ); $condition1->setValidatorsFromForm($operators, $values); @@ -239,10 +239,10 @@ class MatchForXArticlesTest extends \PHPUnit_Framework_TestCase $condition1 = new MatchForXArticles($stubFacade); $operators = array( - MatchForXArticles::INPUT1 => Operators::INFERIOR_OR_EQUAL + MatchForXArticles::CART_QUANTITY => Operators::INFERIOR_OR_EQUAL ); $values = array( - MatchForXArticles::INPUT1 => 4 + MatchForXArticles::CART_QUANTITY => 4 ); $condition1->setValidatorsFromForm($operators, $values); @@ -275,10 +275,10 @@ class MatchForXArticlesTest extends \PHPUnit_Framework_TestCase $condition1 = new MatchForXArticles($stubFacade); $operators = array( - MatchForXArticles::INPUT1 => Operators::INFERIOR_OR_EQUAL + MatchForXArticles::CART_QUANTITY => Operators::INFERIOR_OR_EQUAL ); $values = array( - MatchForXArticles::INPUT1 => 3 + MatchForXArticles::CART_QUANTITY => 3 ); $condition1->setValidatorsFromForm($operators, $values); @@ -311,10 +311,10 @@ class MatchForXArticlesTest extends \PHPUnit_Framework_TestCase $condition1 = new MatchForXArticles($stubFacade); $operators = array( - MatchForXArticles::INPUT1 => Operators::EQUAL + MatchForXArticles::CART_QUANTITY => Operators::EQUAL ); $values = array( - MatchForXArticles::INPUT1 => 4 + MatchForXArticles::CART_QUANTITY => 4 ); $condition1->setValidatorsFromForm($operators, $values); @@ -347,10 +347,10 @@ class MatchForXArticlesTest extends \PHPUnit_Framework_TestCase $condition1 = new MatchForXArticles($stubFacade); $operators = array( - MatchForXArticles::INPUT1 => Operators::EQUAL + MatchForXArticles::CART_QUANTITY => Operators::EQUAL ); $values = array( - MatchForXArticles::INPUT1 => 5 + MatchForXArticles::CART_QUANTITY => 5 ); $condition1->setValidatorsFromForm($operators, $values); @@ -383,10 +383,10 @@ class MatchForXArticlesTest extends \PHPUnit_Framework_TestCase $condition1 = new MatchForXArticles($stubFacade); $operators = array( - MatchForXArticles::INPUT1 => Operators::SUPERIOR_OR_EQUAL + MatchForXArticles::CART_QUANTITY => Operators::SUPERIOR_OR_EQUAL ); $values = array( - MatchForXArticles::INPUT1 => 4 + MatchForXArticles::CART_QUANTITY => 4 ); $condition1->setValidatorsFromForm($operators, $values); @@ -419,10 +419,10 @@ class MatchForXArticlesTest extends \PHPUnit_Framework_TestCase $condition1 = new MatchForXArticles($stubFacade); $operators = array( - MatchForXArticles::INPUT1 => Operators::SUPERIOR_OR_EQUAL + MatchForXArticles::CART_QUANTITY => Operators::SUPERIOR_OR_EQUAL ); $values = array( - MatchForXArticles::INPUT1 => 3 + MatchForXArticles::CART_QUANTITY => 3 ); $condition1->setValidatorsFromForm($operators, $values); @@ -455,10 +455,10 @@ class MatchForXArticlesTest extends \PHPUnit_Framework_TestCase $condition1 = new MatchForXArticles($stubFacade); $operators = array( - MatchForXArticles::INPUT1 => Operators::SUPERIOR_OR_EQUAL + MatchForXArticles::CART_QUANTITY => Operators::SUPERIOR_OR_EQUAL ); $values = array( - MatchForXArticles::INPUT1 => 5 + MatchForXArticles::CART_QUANTITY => 5 ); $condition1->setValidatorsFromForm($operators, $values); @@ -491,10 +491,10 @@ class MatchForXArticlesTest extends \PHPUnit_Framework_TestCase $condition1 = new MatchForXArticles($stubFacade); $operators = array( - MatchForXArticles::INPUT1 => Operators::SUPERIOR + MatchForXArticles::CART_QUANTITY => Operators::SUPERIOR ); $values = array( - MatchForXArticles::INPUT1 => 3 + MatchForXArticles::CART_QUANTITY => 3 ); $condition1->setValidatorsFromForm($operators, $values); @@ -527,10 +527,10 @@ class MatchForXArticlesTest extends \PHPUnit_Framework_TestCase $condition1 = new MatchForXArticles($stubFacade); $operators = array( - MatchForXArticles::INPUT1 => Operators::SUPERIOR + MatchForXArticles::CART_QUANTITY => Operators::SUPERIOR ); $values = array( - MatchForXArticles::INPUT1 => 4 + MatchForXArticles::CART_QUANTITY => 4 ); $condition1->setValidatorsFromForm($operators, $values); @@ -557,10 +557,10 @@ class MatchForXArticlesTest extends \PHPUnit_Framework_TestCase $condition1 = new MatchForXArticles($stubFacade); $operators = array( - MatchForXArticles::INPUT1 => Operators::SUPERIOR + MatchForXArticles::CART_QUANTITY => Operators::SUPERIOR ); $values = array( - MatchForXArticles::INPUT1 => 4 + MatchForXArticles::CART_QUANTITY => 4 ); $condition1->setValidatorsFromForm($operators, $values); @@ -577,44 +577,6 @@ class MatchForXArticlesTest extends \PHPUnit_Framework_TestCase } - public function testGetAvailableOperators() - { - /** @var FacadeInterface $stubFacade */ - $stubFacade = $this->getMockBuilder('\Thelia\Coupon\BaseFacade') - ->disableOriginalConstructor() - ->getMock(); - - $stubFacade->expects($this->any()) - ->method('getNbArticlesInCart') - ->will($this->returnValue(4)); - $stubFacade->expects($this->any()) - ->method('getConditionEvaluator') - ->will($this->returnValue(new ConditionEvaluator())); - - $condition1 = new MatchForXArticles($stubFacade); - $operators = array( - MatchForXArticles::INPUT1 => Operators::SUPERIOR - ); - $values = array( - MatchForXArticles::INPUT1 => 4 - ); - $condition1->setValidatorsFromForm($operators, $values); - - $expected = array( - MatchForXArticles::INPUT1 => array( - Operators::INFERIOR, - Operators::INFERIOR_OR_EQUAL, - Operators::EQUAL, - Operators::SUPERIOR_OR_EQUAL, - Operators::SUPERIOR - ) - ); - $actual = $condition1->getAvailableOperators(); - - $this->assertEquals($expected, $actual); - - } - /** * Generate adapter stub * @@ -687,10 +649,10 @@ class MatchForXArticlesTest extends \PHPUnit_Framework_TestCase /** @var FacadeInterface $stubFacade */ $condition1 = new MatchForXArticles($stubFacade); $operators = array( - MatchForXArticles::INPUT1 => Operators::SUPERIOR + MatchForXArticles::CART_QUANTITY => Operators::SUPERIOR ); $values = array( - MatchForXArticles::INPUT1 => 4 + MatchForXArticles::CART_QUANTITY => 4 ); $condition1->setValidatorsFromForm($operators, $values); @@ -712,10 +674,10 @@ class MatchForXArticlesTest extends \PHPUnit_Framework_TestCase /** @var FacadeInterface $stubFacade */ $condition1 = new MatchForXArticles($stubFacade); $operators = array( - MatchForXArticles::INPUT1 => Operators::SUPERIOR + MatchForXArticles::CART_QUANTITY => Operators::SUPERIOR ); $values = array( - MatchForXArticles::INPUT1 => 4 + MatchForXArticles::CART_QUANTITY => 4 ); $condition1->setValidatorsFromForm($operators, $values); @@ -723,7 +685,7 @@ class MatchForXArticlesTest extends \PHPUnit_Framework_TestCase $validators = array( 'inputs' => array( - MatchForXArticles::INPUT1 => array( + MatchForXArticles::CART_QUANTITY => array( 'availableOperators' => array( '<' => 'Price', '<=' => 'Price', diff --git a/core/lib/Thelia/Tests/Condition/OperatorsTest.php b/core/lib/Thelia/Tests/Condition/OperatorsTest.php index c410fd975..5acd41ced 100644 --- a/core/lib/Thelia/Tests/Condition/OperatorsTest.php +++ b/core/lib/Thelia/Tests/Condition/OperatorsTest.php @@ -52,7 +52,7 @@ class OperatorsTest extends \PHPUnit_Framework_TestCase $this->assertEquals($expected, $actual); $actual = Operators::getI18n($stubTranslator, Operators::EQUAL); - $expected = 'Equals'; + $expected = 'Equal to'; $this->assertEquals($expected, $actual); $actual = Operators::getI18n($stubTranslator, Operators::SUPERIOR_OR_EQUAL); @@ -64,7 +64,7 @@ class OperatorsTest extends \PHPUnit_Framework_TestCase $this->assertEquals($expected, $actual); $actual = Operators::getI18n($stubTranslator, Operators::DIFFERENT); - $expected = 'Not equals'; + $expected = 'Not equal to'; $this->assertEquals($expected, $actual); $actual = Operators::getI18n($stubTranslator, Operators::IN); diff --git a/core/lib/Thelia/Tests/Coupon/CouponFactoryTest.php b/core/lib/Thelia/Tests/Coupon/CouponFactoryTest.php index 8e37e50ec..2971ad5a8 100644 --- a/core/lib/Thelia/Tests/Coupon/CouponFactoryTest.php +++ b/core/lib/Thelia/Tests/Coupon/CouponFactoryTest.php @@ -114,23 +114,23 @@ Sed facilisis pellentesque nisl, eu tincidunt erat scelerisque a. Nullam malesua $condition1 = new MatchForTotalAmount($facade); $operators = array( - MatchForTotalAmount::INPUT1 => Operators::SUPERIOR, - MatchForTotalAmount::INPUT2 => Operators::EQUAL + MatchForTotalAmount::CART_TOTAL => Operators::SUPERIOR, + MatchForTotalAmount::CART_CURRENCY => Operators::EQUAL ); $values = array( - MatchForTotalAmount::INPUT1 => 40.00, - MatchForTotalAmount::INPUT2 => 'EUR' + MatchForTotalAmount::CART_TOTAL => 40.00, + MatchForTotalAmount::CART_CURRENCY => 'EUR' ); $condition1->setValidatorsFromForm($operators, $values); $condition2 = new MatchForTotalAmount($facade); $operators = array( - MatchForTotalAmount::INPUT1 => Operators::INFERIOR, - MatchForTotalAmount::INPUT2 => Operators::EQUAL + MatchForTotalAmount::CART_TOTAL => Operators::INFERIOR, + MatchForTotalAmount::CART_CURRENCY => Operators::EQUAL ); $values = array( - MatchForTotalAmount::INPUT1 => 400.00, - MatchForTotalAmount::INPUT2 => 'EUR' + MatchForTotalAmount::CART_TOTAL => 400.00, + MatchForTotalAmount::CART_CURRENCY => 'EUR' ); $condition2->setValidatorsFromForm($operators, $values); @@ -176,23 +176,23 @@ Sed facilisis pellentesque nisl, eu tincidunt erat scelerisque a. Nullam malesua $condition1 = new MatchForTotalAmount($stubFacade); $operators = array( - MatchForTotalAmount::INPUT1 => Operators::SUPERIOR, - MatchForTotalAmount::INPUT2 => Operators::EQUAL + MatchForTotalAmount::CART_TOTAL => Operators::SUPERIOR, + MatchForTotalAmount::CART_CURRENCY => Operators::EQUAL ); $values = array( - MatchForTotalAmount::INPUT1 => 40.00, - MatchForTotalAmount::INPUT2 => 'EUR' + MatchForTotalAmount::CART_TOTAL => 40.00, + MatchForTotalAmount::CART_CURRENCY => 'EUR' ); $condition1->setValidatorsFromForm($operators, $values); $condition2 = new MatchForTotalAmount($stubFacade); $operators = array( - MatchForTotalAmount::INPUT1 => Operators::INFERIOR, - MatchForTotalAmount::INPUT2 => Operators::EQUAL + MatchForTotalAmount::CART_TOTAL => Operators::INFERIOR, + MatchForTotalAmount::CART_CURRENCY => Operators::EQUAL ); $values = array( - MatchForTotalAmount::INPUT1 => 400.00, - MatchForTotalAmount::INPUT2 => 'EUR' + MatchForTotalAmount::CART_TOTAL => 400.00, + MatchForTotalAmount::CART_CURRENCY => 'EUR' ); $condition2->setValidatorsFromForm($operators, $values); @@ -274,23 +274,23 @@ Sed facilisis pellentesque nisl, eu tincidunt erat scelerisque a. Nullam malesua $condition1 = new MatchForTotalAmount($stubFacade); $operators = array( - MatchForTotalAmount::INPUT1 => Operators::SUPERIOR, - MatchForTotalAmount::INPUT2 => Operators::EQUAL + MatchForTotalAmount::CART_TOTAL => Operators::SUPERIOR, + MatchForTotalAmount::CART_CURRENCY => Operators::EQUAL ); $values = array( - MatchForTotalAmount::INPUT1 => 40.00, - MatchForTotalAmount::INPUT2 => 'EUR' + MatchForTotalAmount::CART_TOTAL => 40.00, + MatchForTotalAmount::CART_CURRENCY => 'EUR' ); $condition1->setValidatorsFromForm($operators, $values); $condition2 = new MatchForTotalAmount($stubFacade); $operators = array( - MatchForTotalAmount::INPUT1 => Operators::INFERIOR, - MatchForTotalAmount::INPUT2 => Operators::EQUAL + MatchForTotalAmount::CART_TOTAL => Operators::INFERIOR, + MatchForTotalAmount::CART_CURRENCY => Operators::EQUAL ); $values = array( - MatchForTotalAmount::INPUT1 => 400.00, - MatchForTotalAmount::INPUT2 => 'EUR' + MatchForTotalAmount::CART_TOTAL => 400.00, + MatchForTotalAmount::CART_CURRENCY => 'EUR' ); $condition2->setValidatorsFromForm($operators, $values); @@ -337,23 +337,23 @@ Sed facilisis pellentesque nisl, eu tincidunt erat scelerisque a. Nullam malesua $condition1 = new MatchForTotalAmount($stubFacade); $operators = array( - MatchForTotalAmount::INPUT1 => Operators::SUPERIOR, - MatchForTotalAmount::INPUT2 => Operators::EQUAL + MatchForTotalAmount::CART_TOTAL => Operators::SUPERIOR, + MatchForTotalAmount::CART_CURRENCY => Operators::EQUAL ); $values = array( - MatchForTotalAmount::INPUT1 => 40.00, - MatchForTotalAmount::INPUT2 => 'EUR' + MatchForTotalAmount::CART_TOTAL => 40.00, + MatchForTotalAmount::CART_CURRENCY => 'EUR' ); $condition1->setValidatorsFromForm($operators, $values); $condition2 = new MatchForTotalAmount($stubFacade); $operators = array( - MatchForTotalAmount::INPUT1 => Operators::INFERIOR, - MatchForTotalAmount::INPUT2 => Operators::EQUAL + MatchForTotalAmount::CART_TOTAL => Operators::INFERIOR, + MatchForTotalAmount::CART_CURRENCY => Operators::EQUAL ); $values = array( - MatchForTotalAmount::INPUT1 => 400.00, - MatchForTotalAmount::INPUT2 => 'EUR' + MatchForTotalAmount::CART_TOTAL => 400.00, + MatchForTotalAmount::CART_CURRENCY => 'EUR' ); $condition2->setValidatorsFromForm($operators, $values); @@ -397,23 +397,23 @@ Sed facilisis pellentesque nisl, eu tincidunt erat scelerisque a. Nullam malesua $condition1 = new MatchForTotalAmount($stubFacade); $operators = array( - MatchForTotalAmount::INPUT1 => Operators::SUPERIOR, - MatchForTotalAmount::INPUT2 => Operators::EQUAL + MatchForTotalAmount::CART_TOTAL => Operators::SUPERIOR, + MatchForTotalAmount::CART_CURRENCY => Operators::EQUAL ); $values = array( - MatchForTotalAmount::INPUT1 => 40.00, - MatchForTotalAmount::INPUT2 => 'EUR' + MatchForTotalAmount::CART_TOTAL => 40.00, + MatchForTotalAmount::CART_CURRENCY => 'EUR' ); $condition1->setValidatorsFromForm($operators, $values); $condition2 = new MatchForTotalAmount($stubFacade); $operators = array( - MatchForTotalAmount::INPUT1 => Operators::INFERIOR, - MatchForTotalAmount::INPUT2 => Operators::EQUAL + MatchForTotalAmount::CART_TOTAL => Operators::INFERIOR, + MatchForTotalAmount::CART_CURRENCY => Operators::EQUAL ); $values = array( - MatchForTotalAmount::INPUT1 => 400.00, - MatchForTotalAmount::INPUT2 => 'EUR' + MatchForTotalAmount::CART_TOTAL => 400.00, + MatchForTotalAmount::CART_CURRENCY => 'EUR' ); $condition2->setValidatorsFromForm($operators, $values); diff --git a/core/lib/Thelia/Tests/Coupon/CouponManagerTest.php b/core/lib/Thelia/Tests/Coupon/CouponManagerTest.php index b14f781bb..79bf4ba9a 100644 --- a/core/lib/Thelia/Tests/Coupon/CouponManagerTest.php +++ b/core/lib/Thelia/Tests/Coupon/CouponManagerTest.php @@ -75,23 +75,23 @@ Sed facilisis pellentesque nisl, eu tincidunt erat scelerisque a. Nullam malesua $condition1 = new MatchForTotalAmount($facade); $operators = array( - MatchForTotalAmount::INPUT1 => Operators::SUPERIOR, - MatchForTotalAmount::INPUT2 => Operators::EQUAL + MatchForTotalAmount::CART_TOTAL => Operators::SUPERIOR, + MatchForTotalAmount::CART_CURRENCY => Operators::EQUAL ); $values = array( - MatchForTotalAmount::INPUT1 => 40.00, - MatchForTotalAmount::INPUT2 => 'EUR' + MatchForTotalAmount::CART_TOTAL => 40.00, + MatchForTotalAmount::CART_CURRENCY => 'EUR' ); $condition1->setValidatorsFromForm($operators, $values); $condition2 = new MatchForTotalAmount($facade); $operators = array( - MatchForTotalAmount::INPUT1 => Operators::INFERIOR, - MatchForTotalAmount::INPUT2 => Operators::EQUAL + MatchForTotalAmount::CART_TOTAL => Operators::INFERIOR, + MatchForTotalAmount::CART_CURRENCY => Operators::EQUAL ); $values = array( - MatchForTotalAmount::INPUT1 => 400.00, - MatchForTotalAmount::INPUT2 => 'EUR' + MatchForTotalAmount::CART_TOTAL => 400.00, + MatchForTotalAmount::CART_CURRENCY => 'EUR' ); $condition2->setValidatorsFromForm($operators, $values); @@ -339,23 +339,23 @@ Sed facilisis pellentesque nisl, eu tincidunt erat scelerisque a. Nullam malesua $condition1 = new MatchForTotalAmount($stubFacade); $operators = array( - MatchForTotalAmount::INPUT1 => Operators::SUPERIOR, - MatchForTotalAmount::INPUT2 => Operators::EQUAL + MatchForTotalAmount::CART_TOTAL => Operators::SUPERIOR, + MatchForTotalAmount::CART_CURRENCY => Operators::EQUAL ); $values = array( - MatchForTotalAmount::INPUT1 => 40.00, - MatchForTotalAmount::INPUT2 => 'EUR' + MatchForTotalAmount::CART_TOTAL => 40.00, + MatchForTotalAmount::CART_CURRENCY => 'EUR' ); $condition1->setValidatorsFromForm($operators, $values); $condition2 = new MatchForTotalAmount($stubFacade); $operators = array( - MatchForTotalAmount::INPUT1 => Operators::INFERIOR, - MatchForTotalAmount::INPUT2 => Operators::EQUAL + MatchForTotalAmount::CART_TOTAL => Operators::INFERIOR, + MatchForTotalAmount::CART_CURRENCY => Operators::EQUAL ); $values = array( - MatchForTotalAmount::INPUT1 => 400.00, - MatchForTotalAmount::INPUT2 => 'EUR' + MatchForTotalAmount::CART_TOTAL => 400.00, + MatchForTotalAmount::CART_CURRENCY => 'EUR' ); $condition2->setValidatorsFromForm($operators, $values); @@ -394,23 +394,23 @@ Sed facilisis pellentesque nisl, eu tincidunt erat scelerisque a. Nullam malesua $condition1 = new MatchForTotalAmount($stubFacade); $operators = array( - MatchForTotalAmount::INPUT1 => Operators::SUPERIOR, - MatchForTotalAmount::INPUT2 => Operators::EQUAL + MatchForTotalAmount::CART_TOTAL => Operators::SUPERIOR, + MatchForTotalAmount::CART_CURRENCY => Operators::EQUAL ); $values = array( - MatchForTotalAmount::INPUT1 => 40.00, - MatchForTotalAmount::INPUT2 => 'EUR' + MatchForTotalAmount::CART_TOTAL => 40.00, + MatchForTotalAmount::CART_CURRENCY => 'EUR' ); $condition1->setValidatorsFromForm($operators, $values); $condition2 = new MatchForTotalAmount($stubFacade); $operators = array( - MatchForTotalAmount::INPUT1 => Operators::INFERIOR, - MatchForTotalAmount::INPUT2 => Operators::EQUAL + MatchForTotalAmount::CART_TOTAL => Operators::INFERIOR, + MatchForTotalAmount::CART_CURRENCY => Operators::EQUAL ); $values = array( - MatchForTotalAmount::INPUT1 => 400.00, - MatchForTotalAmount::INPUT2 => 'EUR' + MatchForTotalAmount::CART_TOTAL => 400.00, + MatchForTotalAmount::CART_CURRENCY => 'EUR' ); $condition2->setValidatorsFromForm($operators, $values); @@ -459,23 +459,23 @@ Sed facilisis pellentesque nisl, eu tincidunt erat scelerisque a. Nullam malesua $condition1 = new MatchForTotalAmount($stubFacade); $operators = array( - MatchForTotalAmount::INPUT1 => Operators::SUPERIOR, - MatchForTotalAmount::INPUT2 => Operators::EQUAL + MatchForTotalAmount::CART_TOTAL => Operators::SUPERIOR, + MatchForTotalAmount::CART_CURRENCY => Operators::EQUAL ); $values = array( - MatchForTotalAmount::INPUT1 => 40.00, - MatchForTotalAmount::INPUT2 => 'EUR' + MatchForTotalAmount::CART_TOTAL => 40.00, + MatchForTotalAmount::CART_CURRENCY => 'EUR' ); $condition1->setValidatorsFromForm($operators, $values); $condition2 = new MatchForTotalAmount($stubFacade); $operators = array( - MatchForTotalAmount::INPUT1 => Operators::INFERIOR, - MatchForTotalAmount::INPUT2 => Operators::EQUAL + MatchForTotalAmount::CART_TOTAL => Operators::INFERIOR, + MatchForTotalAmount::CART_CURRENCY => Operators::EQUAL ); $values = array( - MatchForTotalAmount::INPUT1 => 400.00, - MatchForTotalAmount::INPUT2 => 'EUR' + MatchForTotalAmount::CART_TOTAL => 400.00, + MatchForTotalAmount::CART_CURRENCY => 'EUR' ); $condition2->setValidatorsFromForm($operators, $values); diff --git a/core/lib/Thelia/Tests/Coupon/Type/RemoveXAmountTest.php b/core/lib/Thelia/Tests/Coupon/Type/RemoveXAmountTest.php index da349bb85..b2cd23e13 100644 --- a/core/lib/Thelia/Tests/Coupon/Type/RemoveXAmountTest.php +++ b/core/lib/Thelia/Tests/Coupon/Type/RemoveXAmountTest.php @@ -118,23 +118,23 @@ class RemoveXAmountTest extends \PHPUnit_Framework_TestCase $condition1 = new MatchForTotalAmount($stubFacade); $operators = array( - MatchForTotalAmount::INPUT1 => Operators::SUPERIOR, - MatchForTotalAmount::INPUT2 => Operators::EQUAL + MatchForTotalAmount::CART_TOTAL => Operators::SUPERIOR, + MatchForTotalAmount::CART_CURRENCY => Operators::EQUAL ); $values = array( - MatchForTotalAmount::INPUT1 => 40.00, - MatchForTotalAmount::INPUT2 => 'EUR' + MatchForTotalAmount::CART_TOTAL => 40.00, + MatchForTotalAmount::CART_CURRENCY => 'EUR' ); $condition1->setValidatorsFromForm($operators, $values); $condition2 = new MatchForTotalAmount($stubFacade); $operators = array( - MatchForTotalAmount::INPUT1 => Operators::INFERIOR, - MatchForTotalAmount::INPUT2 => Operators::EQUAL + MatchForTotalAmount::CART_TOTAL => Operators::INFERIOR, + MatchForTotalAmount::CART_CURRENCY => Operators::EQUAL ); $values = array( - MatchForTotalAmount::INPUT1 => 400.00, - MatchForTotalAmount::INPUT2 => 'EUR' + MatchForTotalAmount::CART_TOTAL => 400.00, + MatchForTotalAmount::CART_CURRENCY => 'EUR' ); $condition2->setValidatorsFromForm($operators, $values); diff --git a/core/lib/Thelia/Tests/Coupon/Type/RemoveXPercentTest.php b/core/lib/Thelia/Tests/Coupon/Type/RemoveXPercentTest.php index 4ddeb7d12..d22918b57 100644 --- a/core/lib/Thelia/Tests/Coupon/Type/RemoveXPercentTest.php +++ b/core/lib/Thelia/Tests/Coupon/Type/RemoveXPercentTest.php @@ -107,23 +107,23 @@ class RemoveXPercentTest extends \PHPUnit_Framework_TestCase $condition1 = new MatchForTotalAmount($stubFacade); $operators = array( - MatchForTotalAmount::INPUT1 => Operators::SUPERIOR, - MatchForTotalAmount::INPUT2 => Operators::EQUAL + MatchForTotalAmount::CART_TOTAL => Operators::SUPERIOR, + MatchForTotalAmount::CART_CURRENCY => Operators::EQUAL ); $values = array( - MatchForTotalAmount::INPUT1 => 40.00, - MatchForTotalAmount::INPUT2 => 'EUR' + MatchForTotalAmount::CART_TOTAL => 40.00, + MatchForTotalAmount::CART_CURRENCY => 'EUR' ); $condition1->setValidatorsFromForm($operators, $values); $condition2 = new MatchForTotalAmount($stubFacade); $operators = array( - MatchForTotalAmount::INPUT1 => Operators::INFERIOR, - MatchForTotalAmount::INPUT2 => Operators::EQUAL + MatchForTotalAmount::CART_TOTAL => Operators::INFERIOR, + MatchForTotalAmount::CART_CURRENCY => Operators::EQUAL ); $values = array( - MatchForTotalAmount::INPUT1 => 400.00, - MatchForTotalAmount::INPUT2 => 'EUR' + MatchForTotalAmount::CART_TOTAL => 400.00, + MatchForTotalAmount::CART_CURRENCY => 'EUR' ); $condition2->setValidatorsFromForm($operators, $values); diff --git a/setup/faker.php b/setup/faker.php index 4ae74a0e5..6843097b7 100644 --- a/setup/faker.php +++ b/setup/faker.php @@ -694,23 +694,23 @@ Sed facilisis pellentesque nisl, eu tincidunt erat scelerisque a. Nullam malesua $condition1 = new MatchForTotalAmount($adapter); $operators = array( - MatchForTotalAmount::INPUT1 => Operators::SUPERIOR, - MatchForTotalAmount::INPUT2 => Operators::EQUAL + MatchForTotalAmount::CART_TOTAL => Operators::SUPERIOR, + MatchForTotalAmount::CART_CURRENCY => Operators::EQUAL ); $values = array( - MatchForTotalAmount::INPUT1 => 40.00, - MatchForTotalAmount::INPUT2 => 'EUR' + MatchForTotalAmount::CART_TOTAL => 40.00, + MatchForTotalAmount::CART_CURRENCY => 'EUR' ); $condition1->setValidatorsFromForm($operators, $values); $condition2 = new MatchForTotalAmount($adapter); $operators = array( - MatchForTotalAmount::INPUT1 => Operators::INFERIOR, - MatchForTotalAmount::INPUT2 => Operators::EQUAL + MatchForTotalAmount::CART_TOTAL => Operators::INFERIOR, + MatchForTotalAmount::CART_CURRENCY => Operators::EQUAL ); $values = array( - MatchForTotalAmount::INPUT1 => 400.00, - MatchForTotalAmount::INPUT2 => 'EUR' + MatchForTotalAmount::CART_TOTAL => 400.00, + MatchForTotalAmount::CART_CURRENCY => 'EUR' ); $condition2->setValidatorsFromForm($operators, $values); @@ -754,10 +754,10 @@ Sed facilisis pellentesque nisl, eu tincidunt erat scelerisque a. Nullam malesua $condition1 = new MatchForXArticles($adapter); $operators = array( - MatchForXArticles::INPUT1 => Operators::SUPERIOR, + MatchForXArticles::CART_QUANTITY => Operators::SUPERIOR, ); $values = array( - MatchForXArticles::INPUT1 => 4, + MatchForXArticles::CART_QUANTITY => 4, ); $condition1->setValidatorsFromForm($operators, $values); $conditions = new ConditionCollection(); diff --git a/templates/backOffice/default/I18n/en_US.php b/templates/backOffice/default/I18n/en_US.php index 7d9b897ef..de6a5035b 100644 --- a/templates/backOffice/default/I18n/en_US.php +++ b/templates/backOffice/default/I18n/en_US.php @@ -490,6 +490,7 @@ return array( 'Folder title' => 'Folder title', 'Folders' => 'Folders', 'Folders in %fold' => 'Folders in %fold', + 'Format: %fmt' => 'Format: %fmt ', 'Format: %fmt, e.g. %date' => 'Format: %fmt, e.g. %date', 'French 19.6% VAT is a tax which add a 19.6% tax to the product price.' => 'French 19.6% VAT is a tax which add a 19.6% tax to the product price.', 'French 19.6% VAT with ecotax is the applicance of the ecotax (on the product price) then the applicance of the 19.6% tax (on the product price + the ecotax amount).' => 'French 19.6% VAT with ecotax is the applicance of the ecotax (on the product price) then the applicance of the 19.6% tax (on the product price + the ecotax amount).', @@ -633,6 +634,7 @@ return array( 'Period' => 'Period', 'Phone' => 'Phone', 'Phone number' => 'Phone number', + 'Please enter the date using the %fmt format' => 'Merci d\'indiquer une date au format %fmt', 'Please retry' => 'Please retry', 'Please save this coupon first to define coupon conditions' => 'Please save this coupon first to define coupon conditions', 'Please select a condition' => 'Please select a condition', @@ -773,6 +775,8 @@ return array( 'Short description :' => 'Short description :', 'Show logs' => 'Show logs', 'Some of your translations are not saved. Continue anyway ?' => 'Some of your translations are not saved. Continue anyway ?', + 'Something goes wrong, please try again' => 'Une erreur est survenue, merci de ré-essayer', + 'Something goes wrong, please try again.' => 'Une erreur est survenue, merci de ré-essayer.', 'Sorry, attribute ID=%id was not found.' => 'Sorry, attribute ID=%id was not found.', 'Sorry, country ID=%id was not found.' => 'Sorry, country ID=%id was not found.', 'Sorry, currency ID=%id was not found.' => 'Sorry, currency ID=%id was not found.', @@ -822,6 +826,7 @@ return array( 'The mailing template in text-only format.' => 'The mailing template in text-only format.', 'The page you\'ve requested was not found. Please check the page address, and try again.' => 'The page you\'ve requested was not found. Please check the page address, and try again.', 'The rate from Euro (Price in Euro * rate = Price in this currency)' => 'The rate from Euro (Price in Euro * rate = Price in this currency)', + 'The selected countries :' => 'Les pays sélectionnés :', 'The server returned a "404 Not Found"' => 'The server returned a "404 Not Found"', 'The symbol, such as $, £, €...' => 'The symbol, such as $, £, €...', 'The syntax used is identical to the PHP date() function' => 'The syntax used is identical to the PHP date() function', @@ -836,7 +841,6 @@ return array( 'Thelia Shipping zones' => 'Thelia Shipping zones', 'Thelia System Variables' => 'Thelia System Variables', 'Thelia caches flushing' => 'Thelia caches flushing', - 'Thelia configuration' => 'Thelia configuration', 'Thelia contributions' => 'Thelia contributions', 'Thelia core' => 'Thelia core', 'Thelia informations' => 'Thelia information', @@ -846,7 +850,6 @@ return array( 'Thelia product templates' => 'Thelia product templates', 'Thelia support forum' => 'Thelia support forum', 'Thelia system variables' => 'Thelia system variables', - 'Thelia tools' => 'Thelia tools', 'Thelia, the open source e-commerce solution' => 'Thelia, the open source e-commerce solution', 'There are no shipping zones attached to this module.' => 'There are no shipping zones attached to this module.', 'There is currently no active module here.' => 'There is currently no active module here.', @@ -918,6 +921,7 @@ return array( 'Update this image' => 'Update this image', 'Usage count' => 'Usage count', 'Usages left' => 'Usages left', + 'Use Ctrl+click to select (or deselect) more that one country' => 'Utiliser Ctrl+clic pour sélectionner (ou dé-sélectionner) plusieurs pays.', 'Use Ctrl+click to select more than one value. You can also clear selected values.' => 'Use Ctrl+click to select more than one value. You can also clear selected values.', 'Use HTML message defined below' => 'Use HTML message defined below', 'Use Text message defined below' => 'Use Text message defined below', @@ -930,6 +934,7 @@ return array( 'Username :' => 'Username :', 'Using a domain or subdomain for each language' => 'Using a domain or subdomain for each language', 'Valid on special offers' => 'Valid on special offers', + 'Validity start date' => 'Date de début de validité', 'Value' => 'Value', 'Variable created on %date_create. Last modification: %date_change' => 'Variable created on %date_create. Last modification: %date_change', 'Variable name' => 'Variable name', @@ -971,7 +976,6 @@ return array( 'company' => 'company', 'customer ref' => 'customer ref', 'd-m-Y' => 'd-m-Y', - 'date form' => 'date form', 'date in yyyy-mm-dd format' => 'date in yyyy-mm-dd format', 'deactivate' => 'deactivate', 'deactivation' => 'deactivation', @@ -988,7 +992,6 @@ return array( 'short description' => 'short description', 'tax rules' => 'tax rules', 'taxes' => 'taxes', - 'time form' => 'time form', 'title' => 'title', 'tracking reference' => 'tracking reference', 'uncheck all' => 'uncheck all', diff --git a/templates/backOffice/default/assets/js/coupon.js b/templates/backOffice/default/assets/js/coupon.js index 74b511c82..53f932e12 100644 --- a/templates/backOffice/default/assets/js/coupon.js +++ b/templates/backOffice/default/assets/js/coupon.js @@ -105,6 +105,7 @@ $(function($){ $.couponManager.intlPleaseRetry ); }).always(function() { + $('#condition-save-btn').hide(); // Reload condition summaries ajax $.couponManager.displayConditionsSummary(); }); diff --git a/templates/backOffice/default/coupon-create.html b/templates/backOffice/default/coupon-create.html index b57547415..5d6180277 100644 --- a/templates/backOffice/default/coupon-create.html +++ b/templates/backOffice/default/coupon-create.html @@ -42,7 +42,7 @@ $(function($){ // Url alowing to get coupon inputs $.couponManager.urlAjaxAdminCouponDrawInputs = "{$urlAjaxAdminCouponDrawInputs}"; - $.couponManager.intlPleaseRetry = '{intl l='Please retry'}'; + $.couponManager.intlPleaseRetry = '{intl l='Something goes wrong, please try again.'}'; $.couponManager.intlDoYouReallyWantToSetCouponAvailableForEveryOne = '{intl l='Do you really want to set this coupon available to everyone ?'}'; $.couponManager.intlDoYouReallyWantToDeleteThisCondition = '{intl l='Do you really want to delete this condition ?'}'; }); diff --git a/templates/backOffice/default/coupon-update.html b/templates/backOffice/default/coupon-update.html index 6a943027c..0ef964a99 100644 --- a/templates/backOffice/default/coupon-update.html +++ b/templates/backOffice/default/coupon-update.html @@ -49,7 +49,7 @@ $.couponManager.urlAjaxAdminCouponDrawInputs = '{$urlAjaxAdminCouponDrawInputs}'; $.couponManager.urlAjaxGetConditionInputFromServiceId = '{$urlAjaxGetConditionInputFromServiceId}'; $.couponManager.urlAjaxGetConditionInputFromConditionInterface = '{$urlAjaxGetConditionInputFromConditionInterface}'; - $.couponManager.intlPleaseRetry = '{intl l='Please retry'}'; + $.couponManager.intlPleaseRetry = '{intl l='Something goes wrong, please try again'}'; $.couponManager.intlPleaseSelectAnotherCondition = '{intl l='Please select another condition'}'; $.couponManager.intlDoYouReallyWantToSetCouponAvailableForEveryOne = '{intl l='Do you really want to set this coupon available to everyone ?'}'; $.couponManager.intlDoYouReallyWantToDeleteThisCondition = '{intl l='Do you really want to delete this condition ?'}'; diff --git a/templates/backOffice/default/coupon/condition-fragments/cart-contains-categories-condition.html b/templates/backOffice/default/coupon/condition-fragments/cart-contains-categories-condition.html new file mode 100644 index 000000000..5da1c7469 --- /dev/null +++ b/templates/backOffice/default/coupon/condition-fragments/cart-contains-categories-condition.html @@ -0,0 +1,14 @@ +
+ + {$operatorSelectHtml nofilter} +
+ +
+ + + {intl l='Use Ctrl+click to select (or deselect) more that one category'} +
\ No newline at end of file diff --git a/templates/backOffice/default/coupon/condition-fragments/cart-contains-products-condition.html b/templates/backOffice/default/coupon/condition-fragments/cart-contains-products-condition.html new file mode 100644 index 000000000..9038a2a10 --- /dev/null +++ b/templates/backOffice/default/coupon/condition-fragments/cart-contains-products-condition.html @@ -0,0 +1,14 @@ +
+ + {$operatorSelectHtml nofilter} +
+ +
+ + + {intl l='Use Ctrl+click to select (or deselect) more that one product'} +
\ No newline at end of file diff --git a/templates/backOffice/default/coupon/condition-fragments/countries-condition.html b/templates/backOffice/default/coupon/condition-fragments/countries-condition.html new file mode 100644 index 000000000..0e3fed699 --- /dev/null +++ b/templates/backOffice/default/coupon/condition-fragments/countries-condition.html @@ -0,0 +1,14 @@ +
+ + {$operatorSelectHtml nofilter} +
+ +
+ + + {intl l='Use Ctrl+click to select (or deselect) more that one country'} +
\ No newline at end of file diff --git a/templates/backOffice/default/coupon/condition-fragments/customers-condition.html b/templates/backOffice/default/coupon/condition-fragments/customers-condition.html new file mode 100644 index 000000000..871222224 --- /dev/null +++ b/templates/backOffice/default/coupon/condition-fragments/customers-condition.html @@ -0,0 +1,14 @@ +
+ + {$operatorSelectHtml nofilter} +
+ +
+ + + {intl l='Use Ctrl+click to select (or deselect) more that one country'} +
\ No newline at end of file diff --git a/templates/backOffice/default/coupon/condition-fragments/start-date-condition.html b/templates/backOffice/default/coupon/condition-fragments/start-date-condition.html new file mode 100644 index 000000000..453fe3541 --- /dev/null +++ b/templates/backOffice/default/coupon/condition-fragments/start-date-condition.html @@ -0,0 +1,7 @@ + + +
+ + + {intl l='Please enter the date using the %fmt format' fmt=$dateFormat} +
\ No newline at end of file