Formula

Model for handling price formula data.

Tags
author

Barn2 Plugins support@barn2.com

license

GPL-3.0

copyright

Barn2 Media Ltd

Table of Contents

$custom_functions  : array<string|int, mixed>
A list of custom functions.
$data  : array<string|int, mixed>
The formula data.
$exclude_product_price  : bool
Whether to exclude the product price from the formula.
$option_id  : int
The option ID.
$settings  : array<string|int, mixed>
The option settings.
__construct()  : mixed
Constructor.
check_validity()  : bool
Determines whether the current data is sufficient to evaluate the formula.
exclude_product_price()  : bool
Whether the product product price should be excluded because of the formula.
get_custom_variables()  : array<string|int, mixed>
Gets the price formula variables for the field.
get_expression()  : string
Gets the expression for the executor.
get_formula()  : string
Gets the price formula for the field.
get_valid()  : string
Gets the price formula variables for the field.
get_variables()  : array<string|int, mixed>
Gets the price formula variables for the field.
save()  : mixed
Saves the formula data to the database.
set_custom_variables()  : void
Sets the price formula variables for the field.
set_expression()  : void
Sets the expression for the executor.
set_formula()  : void
Sets the price formula for the field.
set_valid()  : void
Sets the valid status of the formula.
set_variables()  : void
Sets the price formula variables for the field.
update_variable_id()  : mixed
Updates a variable id in the formula.
update_variable_name()  : mixed
Updates a variable name in the formula.

Properties

$custom_functions

A list of custom functions.

private array<string|int, mixed> $custom_functions

The custom functions are provided as an associative array where the key is the function name and the value is the function definition.

Tags

$data

The formula data.

private array<string|int, mixed> $data
Tags

$exclude_product_price

Whether to exclude the product price from the formula.

private bool $exclude_product_price
Tags

$option_id

The option ID.

private int $option_id
Tags

$settings

The option settings.

private array<string|int, mixed> $settings
Tags

Methods

__construct()

Constructor.

public __construct(Option $option) : mixed
Parameters
$option : Option
Tags
throws
InvalidArgumentException

If the option is not an Option or is not a price formula.

Return values
mixed

check_validity()

Determines whether the current data is sufficient to evaluate the formula.

public check_validity() : bool
Tags
Return values
bool

exclude_product_price()

Whether the product product price should be excluded because of the formula.

public exclude_product_price() : bool
Return values
bool

get_custom_variables()

Gets the price formula variables for the field.

public get_custom_variables() : array<string|int, mixed>
Tags
Return values
array<string|int, mixed>

get_expression()

Gets the expression for the executor.

public get_expression() : string
Tags
Return values
string

get_formula()

Gets the price formula for the field.

public get_formula() : string
Tags
Return values
string

get_valid()

Gets the price formula variables for the field.

public get_valid() : string
Tags
Return values
string

get_variables()

Gets the price formula variables for the field.

public get_variables() : array<string|int, mixed>
Tags
Return values
array<string|int, mixed>

save()

Saves the formula data to the database.

public save() : mixed
Tags
Return values
mixed

set_custom_variables()

Sets the price formula variables for the field.

public set_custom_variables(array<string|int, mixed> $variables) : void
Parameters
$variables : array<string|int, mixed>
Tags
Return values
void

set_expression()

Sets the expression for the executor.

public set_expression(string $expression) : void
Parameters
$expression : string
Tags
Return values
void

set_formula()

Sets the price formula for the field.

public set_formula(string $formula) : void
Parameters
$formula : string
Tags
Return values
void

set_valid()

Sets the valid status of the formula.

public set_valid(bool $valid) : void
Parameters
$valid : bool
Tags
Return values
void

set_variables()

Sets the price formula variables for the field.

public set_variables(array<string|int, mixed> $variables) : void
Parameters
$variables : array<string|int, mixed>
Tags
Return values
void

update_variable_id()

Updates a variable id in the formula.

public update_variable_id(int $new_id, int $old_id) : mixed
Parameters
$new_id : int
$old_id : int
Tags
Return values
mixed

update_variable_name()

Updates a variable name in the formula.

public update_variable_name(int $option_id, string $name) : mixed
Parameters
$option_id : int
$name : string
Tags
Return values
mixed

Search results