diff --git a/htdocs/langs/en_US/errors.lang b/htdocs/langs/en_US/errors.lang index 64dcd06cb65..e51bdfc1be0 100644 --- a/htdocs/langs/en_US/errors.lang +++ b/htdocs/langs/en_US/errors.lang @@ -156,6 +156,7 @@ ErrorPriceExpression20=Empty expression ErrorPriceExpression21=Empty result '%s' ErrorPriceExpression22=Negative result '%s' ErrorPriceExpression23=Unknown or non set variable '%s' in %s +ErrorPriceExpression24=Variable '%s' exists but has no value ErrorPriceExpressionInternal=Internal error '%s' ErrorPriceExpressionUnknown=Unknown error '%s' ErrorSrcAndTargetWarehouseMustDiffers=Source and target warehouses must differs diff --git a/htdocs/product/dynamic_price/class/price_parser.class.php b/htdocs/product/dynamic_price/class/price_parser.class.php index 088c15b02aa..c281816e99b 100644 --- a/htdocs/product/dynamic_price/class/price_parser.class.php +++ b/htdocs/product/dynamic_price/class/price_parser.class.php @@ -82,6 +82,7 @@ class PriceParser 17, undefined variable '%s' 21, empty result '%s' 22, negative result '%s' + 24, variable '%s' exists but has no value -2 Args 6, wrong number of arguments (%s given, %s expected) @@ -192,9 +193,12 @@ class PriceParser $expression = str_replace("\n", $this->separator_chr, $expression); foreach ($values as $key => $value) { - if ($value === null) $value = "NULL"; - $expression = str_replace($this->special_chr.$key.$this->special_chr, strval($value), $expression); - } + if ($value === null && strpos($expression, $key) !== false) { + $this->error_parser = array(24, $key); + return -7; + } + $expression = str_replace($this->special_chr.$key.$this->special_chr, strval($value), $expression); + } //Check if there is unfilled variable if (strpos($expression, $this->special_chr) !== false)