class PriceParser (View source)

Class to parse product price expressions

Properties

protected DoliDB $db
int $limit
array<int, null|int|string|array{0: string, 1: string}> $error_parser
?string $error_expr
string $special_chr
string $separator_chr

Methods

__construct($db)

Constructor

string
translatedError()

Returns translated error

parseExpression(Product $product, string $expression, array<string, mixed> $values)

Calculates price based on expression

int
parseProduct(Product $product, array<string, mixed> $extra_values = array())

Calculates product price based on product id and associated expression

parseProductSupplier(ProductFournisseur $product_supplier, array<string, mixed> $extra_values = array())

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

testExpression($product_id, string $expression, $extra_values = array())

Tests string expression for validity

Details

__construct($db)

Constructor

@param DoliDB $db Database handler

Parameters

$db

string translatedError()

Returns translated error

Return Value

string

Translated error

parseExpression(Product $product, string $expression, array<string, mixed> $values)

Calculates price based on expression

Parameters

Product $product

The Product object to get information

string $expression

The expression to parse

array<string, mixed> $values

Strings to replace @return int Return > 0 if OK, < 1 if KO

int parseProduct(Product $product, array<string, mixed> $extra_values = array())

Calculates product price based on product id and associated expression

Parameters

Product $product

The Product object to get information

array<string, mixed> $extra_values

Any additional values for expression

Return Value

int

Return > 0 if OK, < 1 if KO

parseProductSupplier(ProductFournisseur $product_supplier, array<string, mixed> $extra_values = array())

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

Parameters

ProductFournisseur $product_supplier

The Product supplier object to get information

array<string, mixed> $extra_values

Any additional values for expression @return int Return > 0 if OK, < 1 if KO

testExpression($product_id, string $expression, $extra_values = array())

Tests string expression for validity

@param int $product_id The Product id to get information

Parameters

$product_id
string $expression

The expression to parse @param array<string,mixed> $extra_values Any additional values for expression @return int Return > 0 if OK, < 1 if KO

$extra_values