Price
Pricing utilities.
Tags
Table of Contents
- calculate_option_cart_price() : float
- Calculates the price for a chosen option choice.
- calculate_option_display_price() : float
- Calculates the display price for a chosen option choice.
- get_choice_display_price() : float|string
- Get display price for a an option choice.
- get_currency_data() : array<string|int, mixed>
- Get currency data about the store currency.
- get_custom_functions() : array<string|int, mixed>
- get_formatted_price() : string
- Get a formatted price for display.
- get_logical_functions() : array<string|int, mixed>
- get_price_html() : string
- Get a formatted price with currency symbol for display.
- get_price_with_applicable_tax() : float|string
- Get price based on tax settings.
- has_conflicting_tax_settings() : bool
- wholesale_user_has_choice_pricing() : bool|float
- Determine if the current user has a wholesale role with set choice pricing for the given choice.
Methods
calculate_option_cart_price()
Calculates the price for a chosen option choice.
public
static calculate_option_cart_price(array<string|int, mixed> $price_data, WC_Product $product[, int $quantity = 1 ][, float $product_price = 0.0 ]) : float
Parameters
- $price_data : array<string|int, mixed>
- $product : WC_Product
- $quantity : int = 1
- $product_price : float = 0.0
Tags
Return values
float —calculate_option_display_price()
Calculates the display price for a chosen option choice.
public
static calculate_option_display_price(array<string|int, mixed> $price_data, WC_Product $product[, int $quantity = 1 ][, string|null $display_area = null ][, float|null $product_price = null ]) : float
Parameters
- $price_data : array<string|int, mixed>
- $product : WC_Product
- $quantity : int = 1
- $display_area : string|null = null
- $product_price : float|null = null
Tags
Return values
float —get_choice_display_price()
Get display price for a an option choice.
public
static get_choice_display_price(WC_Product $product, float $choice_price[, string|null $display_area = null ]) : float|string
Parameters
- $product : WC_Product
- $choice_price : float
- $display_area : string|null = null
Tags
Return values
float|string —$price
get_currency_data()
Get currency data about the store currency.
public
static get_currency_data() : array<string|int, mixed>
For use in JS.
Tags
Return values
array<string|int, mixed> —get_custom_functions()
public
static get_custom_functions() : array<string|int, mixed>
Tags
Return values
array<string|int, mixed> —get_formatted_price()
Get a formatted price for display.
public
static get_formatted_price(float $price) : string
Parameters
- $price : float
Tags
Return values
string —get_logical_functions()
public
static get_logical_functions() : array<string|int, mixed>
Tags
Return values
array<string|int, mixed> —get_price_html()
Get a formatted price with currency symbol for display.
public
static get_price_html(float|string $price) : string
We don't use wc_price for option choices because it is subject to interference by HTMLElement class targeting from third party themes and plugins.
Parameters
- $price : float|string
-
The price you want to format for display.
Tags
Return values
string —$price_html
get_price_with_applicable_tax()
Get price based on tax settings.
public
static get_price_with_applicable_tax(WC_Product $product, float $price, bool $tax_display) : float|string
Parameters
- $product : WC_Product
- $price : float
- $tax_display : bool
Tags
Return values
float|string —Empty string if price cannot be calculated.
has_conflicting_tax_settings()
public
static has_conflicting_tax_settings() : bool
Tags
Return values
bool —wholesale_user_has_choice_pricing()
Determine if the current user has a wholesale role with set choice pricing for the given choice.
public
static wholesale_user_has_choice_pricing(array<string|int, mixed> $choice) : bool|float
Parameters
- $choice : array<string|int, mixed>