Skip to content

Commit b4bb58c

Browse files
author
Alexey Yakimovich
committed
MAGETWO-91657: Advanced pricing the bulk discounts by percentage returns error when set
- Added new validation rule for percentage value;
1 parent 78327c1 commit b4bb58c

File tree

2 files changed

+19
-3
lines changed
  • app/code/Magento

2 files changed

+19
-3
lines changed

app/code/Magento/Catalog/Ui/DataProvider/Product/Form/Modifier/TierPrice.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -154,9 +154,7 @@ private function getUpdatedTierPriceStructure(array $priceMeta)
154154
'addbefore' => '%',
155155
'validation' => [
156156
'required-entry' => true,
157-
'validate-number' => true,
158-
'validate-greater-than-zero' => true,
159-
'less-than-equals-to' => 100
157+
'validate-positive-percent-decimal' => true
160158
],
161159
'visible' => $firstOption
162160
&& $firstOption['value'] == ProductPriceOptionsInterface::VALUE_PERCENT,

app/code/Magento/Ui/view/base/web/js/lib/validation/rules.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -686,6 +686,24 @@ define([
686686
},
687687
$.mage.__('The value is not within the specified range.')
688688
],
689+
'validate-positive-percent-decimal': [
690+
function (value) {
691+
var numValue;
692+
693+
if (utils.isEmptyNoTrim(value) || !/^\s*-?\d*(\.\d*)?\s*$/.test(value)) {
694+
return false;
695+
}
696+
697+
numValue = utils.parseNumber(value);
698+
699+
if (isNaN(numValue)) {
700+
return false;
701+
}
702+
703+
return utils.isBetween(numValue, 0.01, 100);
704+
},
705+
$.mage.__('Please enter a valid percentage discount value greater than 0.')
706+
],
689707
'validate-digits': [
690708
function (value) {
691709
return utils.isEmptyNoTrim(value) || !/[^\d]/.test(value);

0 commit comments

Comments
 (0)