dolibarr 21.0.0-beta
PriceParser Class Reference

Class to parse product price expressions. More...

Public Member Functions

 __construct ($db)
 Constructor.
 
 translatedError ()
 Returns translated error.
 
 parseExpression ($product, $expression, $values)
 Calculates price based on expression.
 
 parseProduct ($product, $extra_values=array())
 Calculates product price based on product id and associated expression.
 
 parseProductSupplier ($product_supplier, $extra_values=array())
 Calculates supplier product price based on product supplier price and associated expression.
 
 testExpression ($product_id, $expression, $extra_values=array())
 Tests string expression for validity.
 

Detailed Description

Class to parse product price expressions.

Definition at line 34 of file price_parser.class.php.

Constructor & Destructor Documentation

◆ __construct()

PriceParser::__construct ( $db)

Constructor.

Parameters
DoliDB$dbDatabase handler

Definition at line 66 of file price_parser.class.php.

Member Function Documentation

◆ parseExpression()

PriceParser::parseExpression ( $product,
$expression,
$values )

Calculates price based on expression.

Parameters
Product$productThe Product object to get information
string$expressionThe expression to parse
array<string,mixed>$values Strings to replace
Returns
int > 0 if OK, < 1 if KO

Definition at line 138 of file price_parser.class.php.

References dol_now().

Referenced by parseProduct(), parseProductSupplier(), and testExpression().

◆ parseProduct()

PriceParser::parseProduct ( $product,
$extra_values = array() )

Calculates product price based on product id and associated expression.

Parameters
Product$productThe Product object to get information
array<string,mixed>$extra_values Any additional values for expression
Returns
int > 0 if OK, < 1 if KO

Definition at line 266 of file price_parser.class.php.

References parseExpression().

◆ parseProductSupplier()

PriceParser::parseProductSupplier ( $product_supplier,
$extra_values = array() )

Calculates supplier product price based on product supplier price and associated expression.

Parameters
ProductFournisseur$product_supplierThe Product supplier object to get information
array<string,mixed>$extra_values Any additional values for expression
Returns
int > 0 if OK, < 1 if KO

Definition at line 313 of file price_parser.class.php.

References parseExpression().

◆ testExpression()

PriceParser::testExpression ( $product_id,
$expression,
$extra_values = array() )

Tests string expression for validity.

Parameters
int$product_idThe Product id to get information
string$expressionThe expression to parse
array<string,mixed>$extra_values Any additional values for expression
Returns
int > 0 if OK, < 1 if KO

Definition at line 344 of file price_parser.class.php.

References parseExpression().

◆ translatedError()

PriceParser::translatedError ( )

Returns translated error.

Returns
string Translated error

Definition at line 76 of file price_parser.class.php.


The documentation for this class was generated from the following file: