diff --git a/features/product_quantity_price_rules/simple_quantity_price_rule.feature b/features/product_quantity_price_rules/simple_quantity_price_rule.feature index c4d332ed18..47a542bfdd 100644 --- a/features/product_quantity_price_rules/simple_quantity_price_rule.feature +++ b/features/product_quantity_price_rules/simple_quantity_price_rule.feature @@ -11,7 +11,7 @@ Feature: Adding a new product with a simple quantity price rule Scenario: Add a quantity price rule with no conditions Given adding a quantity price rule to product "Shoe" named "default-product-quantity-price-rule" and with calculation-behaviour "volume" And the quantity price rule is active - And the quantity price rule has a range from 0 to 10 with behaviour percentage-decrease of 10% + And the quantity price rule has a range starting from 0 with behaviour percentage-decrease of 10% Then the quantity price rule should be valid for product "Shoe" And the product "Shoe" should be priced at "10000" Given I add the product "Shoe" to my cart diff --git a/src/CoreShop/Behat/Context/Setup/ProductQuantityPriceRuleContext.php b/src/CoreShop/Behat/Context/Setup/ProductQuantityPriceRuleContext.php index 3e87503349..01d686311d 100644 --- a/src/CoreShop/Behat/Context/Setup/ProductQuantityPriceRuleContext.php +++ b/src/CoreShop/Behat/Context/Setup/ProductQuantityPriceRuleContext.php @@ -140,10 +140,10 @@ public function theProductQuantityPriceRuleIsInActive(ProductQuantityPriceRuleIn } /** - * @Given /^the (quantity price rule "[^"]+") has a range from ([^"]+) to ([^"]+) with behaviour percentage-decrease of ([^"]+)%$/ - * @Given /^the (quantity price rule) has a range from ([^"]+) to ([^"]+) with behaviour percentage-decrease of ([^"]+)%$/ + * @Given /^the (quantity price rule "[^"]+") has a range starting from ([^"]+) with behaviour percentage-decrease of ([^"]+)%$/ + * @Given /^the (quantity price rule) has a range starting from ([^"]+) with behaviour percentage-decrease of ([^"]+)%$/ */ - public function theProductQuantityPriceRuleHasRangePercentageDecrease(ProductQuantityPriceRuleInterface $rule, int $from, int $to, $percentage) + public function theProductQuantityPriceRuleHasRangePercentageDecrease(ProductQuantityPriceRuleInterface $rule, int $from, $percentage) { /** * @var QuantityRangeInterface $range @@ -151,17 +151,16 @@ public function theProductQuantityPriceRuleHasRangePercentageDecrease(ProductQua $range = $this->rangeFactory->createNew(); $range->setPricingBehaviour('percentage_decrease'); $range->setPercentage($percentage); - $range->setRangeFrom($from); - $range->setRangeTo($to); + $range->setRangeStartingFrom($from); $this->addRange($rule, $range); } /** - * @Given /^the (quantity price rule "[^"]+") has a range from ([^"]+) to ([^"]+) with behaviour percentage-increase of ([^"]+)%$/ - * @Given /^the (quantity price rule) has a range from ([^"]+) to ([^"]+) with behaviour percentage-increase of ([^"]+)%$/ + * @Given /^the (quantity price rule "[^"]+") has a range starting from to ([^"]+) with behaviour percentage-increase of ([^"]+)%$/ + * @Given /^the (quantity price rule) has a range starting from ([^"]+) with behaviour percentage-increase of ([^"]+)%$/ */ - public function theProductQuantityPriceRuleHasRangePercentageIncrease(ProductQuantityPriceRuleInterface $rule, int $from, int $to, $percentage) + public function theProductQuantityPriceRuleHasRangePercentageIncrease(ProductQuantityPriceRuleInterface $rule, int $from, $percentage) { /** * @var QuantityRangeInterface $range @@ -169,20 +168,18 @@ public function theProductQuantityPriceRuleHasRangePercentageIncrease(ProductQua $range = $this->rangeFactory->createNew(); $range->setPricingBehaviour('percentage_increase'); $range->setPercentage($percentage); - $range->setRangeFrom($from); - $range->setRangeTo($to); + $range->setRangeStartingFrom($from); $this->addRange($rule, $range); } /** - * @Given /^the (quantity price rule "[^"]+") has a range from ([^"]+) to ([^"]+) with behaviour amount-decrease of ([^"]+) in (currency "[^"]+")$/ - * @Given /^the (quantity price rule) has a range from ([^"]+) to ([^"]+) with behaviour amount-decrease of ([^"]+) in (currency "[^"]+")$/ + * @Given /^the (quantity price rule "[^"]+") has a range starting from ([^"]+) with behaviour amount-decrease of ([^"]+) in (currency "[^"]+")$/ + * @Given /^the (quantity price rule) has a range starting from ([^"]+) with behaviour amount-decrease of ([^"]+) in (currency "[^"]+")$/ */ public function theProductQuantityPriceRuleHasRangeAmountDecrease( ProductQuantityPriceRuleInterface $rule, int $from, - int $to, $amount, CurrencyInterface $currency ) { @@ -192,21 +189,19 @@ public function theProductQuantityPriceRuleHasRangeAmountDecrease( $range = $this->rangeFactory->createNew(); $range->setPricingBehaviour('amount_decrease'); $range->setAmount($amount); - $range->setRangeFrom($from); - $range->setRangeTo($to); + $range->setRangeStartingFrom($from); $range->setCurrency($currency); $this->addRange($rule, $range); } /** - * @Given /^the (quantity price rule "[^"]+") has a range from ([^"]+) to ([^"]+) with behaviour amount-increase of ([^"]+) in (currency "[^"]+")$/ - * @Given /^the (quantity price rule) has a range from ([^"]+) to ([^"]+) with behaviour amount-increase of ([^"]+) in (currency "[^"]+")$/ + * @Given /^the (quantity price rule "[^"]+") has a range starting from ([^"]+) with behaviour amount-increase of ([^"]+) in (currency "[^"]+")$/ + * @Given /^the (quantity price rule) has a range starting from ([^"]+) with behaviour amount-increase of ([^"]+) in (currency "[^"]+")$/ */ public function theProductQuantityPriceRuleHasRangeAmountIncrease( ProductQuantityPriceRuleInterface $rule, int $from, - int $to, $amount, CurrencyInterface $currency ) { @@ -216,18 +211,17 @@ public function theProductQuantityPriceRuleHasRangeAmountIncrease( $range = $this->rangeFactory->createNew(); $range->setPricingBehaviour('amount_increase'); $range->setAmount($amount); - $range->setRangeFrom($from); - $range->setRangeTo($to); + $range->setRangeStartingFrom($from); $range->setCurrency($currency); $this->addRange($rule, $range); } /** - * @Given /^the (quantity price rule "[^"]+") has a range from ([^"]+) to ([^"]+) with behaviour fixed of ([^"]+) in (currency "[^"]+")$/ - * @Given /^the (quantity price rule) has a range from ([^"]+) to ([^"]+) with behaviour fixed of ([^"]+) in (currency "[^"]+")$/ + * @Given /^the (quantity price rule "[^"]+") has a range starting from ([^"]+) with behaviour fixed of ([^"]+) in (currency "[^"]+")$/ + * @Given /^the (quantity price rule) has a range starting from ([^"]+) with behaviour fixed of ([^"]+) in (currency "[^"]+")$/ */ - public function theProductQuantityPriceRuleHasRangeFixed(ProductQuantityPriceRuleInterface $rule, int $from, int $to, $amount, CurrencyInterface $currency) + public function theProductQuantityPriceRuleHasRangeFixed(ProductQuantityPriceRuleInterface $rule, int $from, $amount, CurrencyInterface $currency) { /** * @var QuantityRangeInterface $range @@ -235,8 +229,7 @@ public function theProductQuantityPriceRuleHasRangeFixed(ProductQuantityPriceRul $range = $this->rangeFactory->createNew(); $range->setPricingBehaviour('fixed'); $range->setAmount($amount); - $range->setRangeFrom($from); - $range->setRangeTo($to); + $range->setRangeStartingFrom($from); $range->setCurrency($currency); $this->addRange($rule, $range); diff --git a/src/CoreShop/Bundle/CoreBundle/Form/Extension/ProductQuantityRangeCollectionTypeExtension.php b/src/CoreShop/Bundle/CoreBundle/Form/Extension/ProductQuantityRangeCollectionTypeExtension.php index a422620ca0..ebba0edc39 100644 --- a/src/CoreShop/Bundle/CoreBundle/Form/Extension/ProductQuantityRangeCollectionTypeExtension.php +++ b/src/CoreShop/Bundle/CoreBundle/Form/Extension/ProductQuantityRangeCollectionTypeExtension.php @@ -51,9 +51,8 @@ public function buildForm(FormBuilderInterface $builder, array $options) } $dataCheck[$unit][] = [ - 'row' => $realRowIndex, - 'from' => $quantityRange->getRangeFrom(), - 'to' => $quantityRange->getRangeTo(), + 'row' => $realRowIndex, + 'startingFrom' => $quantityRange->getRangeStartingFrom() ]; } @@ -71,29 +70,20 @@ public function buildForm(FormBuilderInterface $builder, array $options) foreach ($quantityRangesToCheck as $quantityRange) { $realRowIndex = $quantityRange['row']; - $from = $quantityRange['from']; - $to = $quantityRange['to']; + $startingFrom = $quantityRange['startingFrom']; - if (!is_numeric($from)) { - $form->addError(new FormError('Field "from" in row ' . $realRowIndex . ' needs to be numeric')); + if (!is_numeric($startingFrom)) { + $form->addError(new FormError('Field "starting from" in row ' . $realRowIndex . ' needs to be numeric')); break; - } elseif ((int) $from < 0) { - $form->addError(new FormError('Field "from" in row ' . $realRowIndex . ' needs to be greater or equal than 0')); + } elseif ((int) $startingFrom < 0) { + $form->addError(new FormError('Field "starting from" in row ' . $realRowIndex . ' needs to be greater or equal than 0')); break; - } elseif ((int) $from < $lastEnd) { - $form->addError(new FormError('Field "from" in row ' . $realRowIndex . ' needs to be greater than ' . $lastEnd)); + } elseif ((int) $startingFrom <= $lastEnd) { + $form->addError(new FormError('Field "starting from" in row ' . $realRowIndex . ' needs to be greater than ' . $lastEnd)); break; } - if (!is_numeric($to)) { - $form->addError(new FormError('Field "to" in row ' . $realRowIndex . ' needs to be numeric')); - break; - } elseif ((int) $to < $from) { - $form->addError(new FormError('Field "to" in row ' . $realRowIndex . ' needs to be greater than ' . $from)); - break; - } - - $lastEnd = (int) $to; + $lastEnd = (int) $startingFrom; } } }); diff --git a/src/CoreShop/Bundle/CoreBundle/Resources/public/pimcore/js/productquantitypricerules/ranges.js b/src/CoreShop/Bundle/CoreBundle/Resources/public/pimcore/js/productquantitypricerules/ranges.js index 9fc8f3fb05..025b6ccaf2 100644 --- a/src/CoreShop/Bundle/CoreBundle/Resources/public/pimcore/js/productquantitypricerules/ranges.js +++ b/src/CoreShop/Bundle/CoreBundle/Resources/public/pimcore/js/productquantitypricerules/ranges.js @@ -80,8 +80,7 @@ coreshop.product_quantity_price_rules.ranges = Class.create(coreshop.product_qua grid.getStore().each(function (record) { ranges.push({ 'id': record.get('rangeId'), - 'rangeFrom': record.get('rangeFrom'), - 'rangeTo': record.get('rangeTo'), + 'rangeStartingFrom': record.get('rangeStartingFrom'), 'pricingBehaviour': record.get('pricingBehaviour'), 'unitDefinition': record.get('unitDefinition'), 'amount': record.get('amount'), diff --git a/src/CoreShop/Bundle/CoreBundle/Validator/Constraints/QuantityRangePriceCurrencyAware.php b/src/CoreShop/Bundle/CoreBundle/Validator/Constraints/QuantityRangePriceCurrencyAware.php index 17445e95b8..a48939059b 100644 --- a/src/CoreShop/Bundle/CoreBundle/Validator/Constraints/QuantityRangePriceCurrencyAware.php +++ b/src/CoreShop/Bundle/CoreBundle/Validator/Constraints/QuantityRangePriceCurrencyAware.php @@ -16,5 +16,5 @@ class QuantityRangePriceCurrencyAware extends Constraint { - public $message = '{{ range }} needs a valid currency to work.'; + public $message = '{{ rangeStartingFrom }} needs a valid currency to work.'; } diff --git a/src/CoreShop/Bundle/CoreBundle/Validator/Constraints/QuantityRangePriceCurrencyAwareValidator.php b/src/CoreShop/Bundle/CoreBundle/Validator/Constraints/QuantityRangePriceCurrencyAwareValidator.php index 0a1589398a..eef8c6fec0 100644 --- a/src/CoreShop/Bundle/CoreBundle/Validator/Constraints/QuantityRangePriceCurrencyAwareValidator.php +++ b/src/CoreShop/Bundle/CoreBundle/Validator/Constraints/QuantityRangePriceCurrencyAwareValidator.php @@ -35,7 +35,7 @@ public function validate($value, Constraint $constraint) if (!$value->getCurrency() instanceof CurrencyInterface) { $this->context->buildViolation($constraint->message) - ->setParameter('{{ range }}', sprintf('Range from %d to %d', $value->getRangeFrom(), $value->getRangeTo())) + ->setParameter('{{ rangeStartingFrom }}', sprintf('Range starting from %d', $value->getRangeStartingFrom())) ->addViolation(); } } diff --git a/src/CoreShop/Bundle/FrontendBundle/Resources/views/ProductQuantityPriceRanges/quantity_price_ranges_volume.html.twig b/src/CoreShop/Bundle/FrontendBundle/Resources/views/ProductQuantityPriceRanges/quantity_price_ranges_volume.html.twig index 9b6550de4a..d54e252a07 100644 --- a/src/CoreShop/Bundle/FrontendBundle/Resources/views/ProductQuantityPriceRanges/quantity_price_ranges_volume.html.twig +++ b/src/CoreShop/Bundle/FrontendBundle/Resources/views/ProductQuantityPriceRanges/quantity_price_ranges_volume.html.twig @@ -53,7 +53,7 @@ {% for range in sorted_unit_range.ranges %}