diff --git a/bundles/EcommerceFrameworkBundle/PricingManager/Action/CartDiscount.php b/bundles/EcommerceFrameworkBundle/PricingManager/Action/CartDiscount.php index 079747eb6af..5ca9ba07917 100644 --- a/bundles/EcommerceFrameworkBundle/PricingManager/Action/CartDiscount.php +++ b/bundles/EcommerceFrameworkBundle/PricingManager/Action/CartDiscount.php @@ -91,9 +91,17 @@ public function fromJSON($string) { $json = json_decode($string); if ($json->amount) { + if($json->amount < 0) { + throw new \Exception('Only positive numbers and 0 are valid values for absolute discounts'); + } + $this->setAmount($json->amount); } if ($json->percent) { + if($json->percent < 0) { + throw new \Exception('Only positive numbers and 0 are valid values for % discounts'); + } + $this->setPercent($json->percent); } diff --git a/bundles/EcommerceFrameworkBundle/PricingManager/Action/ProductDiscount.php b/bundles/EcommerceFrameworkBundle/PricingManager/Action/ProductDiscount.php index e9c2faca6e6..75237eab63e 100644 --- a/bundles/EcommerceFrameworkBundle/PricingManager/Action/ProductDiscount.php +++ b/bundles/EcommerceFrameworkBundle/PricingManager/Action/ProductDiscount.php @@ -75,9 +75,17 @@ public function fromJSON($string) { $json = json_decode($string); if ($json->amount) { + if($json->amount < 0) { + throw new \Exception('Only positive numbers and 0 are valid values for absolute discounts'); + } + $this->setAmount($json->amount); } if ($json->percent) { + if($json->percent < 0) { + throw new \Exception('Only positive numbers and 0 are valid values for % discounts'); + } + $this->setPercent($json->percent); } diff --git a/bundles/EcommerceFrameworkBundle/Resources/public/js/pricing/config/item.js b/bundles/EcommerceFrameworkBundle/Resources/public/js/pricing/config/item.js index d8d189c7d4c..ccf84a4b2ed 100644 --- a/bundles/EcommerceFrameworkBundle/Resources/public/js/pricing/config/item.js +++ b/bundles/EcommerceFrameworkBundle/Resources/public/js/pricing/config/item.js @@ -1408,13 +1408,16 @@ pimcore.bundle.EcommerceFramework.pricing.actions = { fieldLabel: t("bundle_ecommerce_pricing_config_action_cart_discount_amount"), name: "amount", width: 200, - value: data.amount + value: data.amount, + minValue: 0 }, { xtype: "numberfield", fieldLabel: t("bundle_ecommerce_pricing_config_action_cart_discount_percent"), name: "percent", width: 200, - value: data.percent + value: data.percent, + maxValue: 100, + minValue: 0 } ] }); @@ -1460,13 +1463,16 @@ pimcore.bundle.EcommerceFramework.pricing.actions = { fieldLabel: t("bundle_ecommerce_pricing_config_action_product_discount_amount"), name: "amount", width: 200, - value: data.amount + value: data.amount, + minValue: 0 }, { xtype: "numberfield", fieldLabel: t("bundle_ecommerce_pricing_config_action_product_discount_percent"), name: "percent", width: 200, - value: data.percent + value: data.percent, + maxValue: 100, + minValue: 0 } ] });