Cart_Item_Data_Formula
Tags
Table of Contents
- evaluate_formula() : float|null
- Evaluates the formula for the field.
- get_cart_item_data() : array<string|int, mixed>
- Retrieves the cart item data for the selected value(s) of the field.
- get_math_executor() : MathExecutor
- Create a new MathExecutor instance and add custom functions.
- get_option_variable_value() : float|null
- Checks if the formula is valid.
- get_product_variable_value() : float
- Get the values for product based variables.
- is_valid_option_variable() : object|null
- Checks if the supplied option variable is valid.
- process_choice_value() : mixed
- process_value() : mixed
Methods
evaluate_formula()
Evaluates the formula for the field.
public
evaluate_formula(array<string|int, mixed> $options, int $quantity) : float|null
Parameters
- $options : array<string|int, mixed>
- $quantity : int
Tags
Return values
float|null —get_cart_item_data()
Retrieves the cart item data for the selected value(s) of the field.
public
get_cart_item_data(mixed $value, WC_Product $product, int $quantity, array<string|int, mixed> $options) : array<string|int, mixed>
Parameters
- $value : mixed
- $product : WC_Product
- $quantity : int
- $options : array<string|int, mixed>
Tags
Return values
array<string|int, mixed> —get_math_executor()
Create a new MathExecutor instance and add custom functions.
public
get_math_executor() : MathExecutor
Tags
Return values
MathExecutor —get_option_variable_value()
Checks if the formula is valid.
private
get_option_variable_value(object $option, array<string|int, mixed> $options, array<string|int, mixed> $formula_variable, mixed $quantity) : float|null
Parameters
- $option : object
- $options : array<string|int, mixed>
- $formula_variable : array<string|int, mixed>
- $quantity : mixed
Tags
Return values
float|null —get_product_variable_value()
Get the values for product based variables.
private
get_product_variable_value(string $id, int $quantity) : float
Parameters
- $id : string
- $quantity : int
Tags
Return values
float —is_valid_option_variable()
Checks if the supplied option variable is valid.
private
is_valid_option_variable(array<string|int, mixed> $formula_variable, array<string|int, mixed> $options) : object|null
Parameters
- $formula_variable : array<string|int, mixed>
- $options : array<string|int, mixed>
Tags
Return values
object|null —process_choice_value()
private
process_choice_value(mixed $value, mixed $option, mixed $formula_variable) : mixed
Parameters
- $value : mixed
- $option : mixed
- $formula_variable : mixed
Tags
Return values
mixed —process_value()
private
process_value(mixed $value, mixed $option, mixed $formula_variable, mixed $options, mixed $quantity) : mixed
Parameters
- $value : mixed
- $option : mixed
- $formula_variable : mixed
- $options : mixed
- $quantity : mixed