Price_Handler implements Registerable, Standard_Service

Handles the display of wholesale prices

Tags
author

Barn2 Plugins support@barn2.com

license

GPL-3.0

copyright

Barn2 Media Ltd

Interfaces, Classes and Traits

Registerable
Standard_Service

Table of Contents

add_inline_css()  : void
Add inline CSS to fix the display of the wholesale price range
add_sale_price_filter()  : void
Add the sale price filter once there is no risks of endless loop
clear_all_transients()  : mixed
Delete all wholesale price transients
clear_product_transients()  : mixed
Delete all wholesale price transients for a specific product
clear_role_transients()  : mixed
Delete all wholesale price transients for a specific role
clear_transients_with_woocommerce()  : mixed
disable_sale_flash()  : string
Disables the Sale Tag
get_price()  : float
Filters the product price
get_price_html()  : string
Outputs the wholesale price html
get_sale_price()  : float
Filters the product sale price
has_price_changed()  : bool
Determine whether the product price has changed
is_on_sale()  : bool
Determine whether a product is on sale based on the wholesale role of the user currently logged in
register()  : mixed
{@inheritdoc}
remove_sale_price_filter()  : void
Remove the sale price filter to avoid endless loop within the `woocommerce_product_get_sale_price` filter
show_variation_prices()  : bool
Show variation prices for wholesale always
update_product()  : mixed
Clears the product transients
variation_prices()  : array<string|int, mixed>
Alter the array with the variation prices
variation_prices_hash()  : array<string|int, mixed>
Add a custom price hash for the variation price range cache
disregard_wholesale_pricing()  : bool
Determine whether to disregard the wholesale pricing

Methods

add_inline_css()

Add inline CSS to fix the display of the wholesale price range

public add_inline_css() : void
Tags
Return values
void

add_sale_price_filter()

Add the sale price filter once there is no risks of endless loop

public add_sale_price_filter() : void
Tags
Return values
void

clear_all_transients()

Delete all wholesale price transients

public clear_all_transients() : mixed
Tags
Return values
mixed

clear_product_transients()

Delete all wholesale price transients for a specific product

public clear_product_transients(int $product_id) : mixed
Parameters
$product_id : int
Tags
Return values
mixed

clear_role_transients()

Delete all wholesale price transients for a specific role

public clear_role_transients(string $role_name) : mixed
Parameters
$role_name : string
Tags
Return values
mixed

clear_transients_with_woocommerce()

public clear_transients_with_woocommerce(mixed $product_id) : mixed
Parameters
$product_id : mixed
Tags
Return values
mixed

disable_sale_flash()

Disables the Sale Tag

public disable_sale_flash(string $html, WP_Post $post, WC_Product $product) : string
Parameters
$html : string
$post : WP_Post
$product : WC_Product
Tags
Return values
string

$html

get_price()

Filters the product price

public get_price(string|float $price, WC_Product $product[, bool $strict = false ]) : float
Parameters
$price : string|float

The product price

$product : WC_Product

The product object

$strict : bool = false

Whether to return the price without any sale price considerations

Tags
Return values
float

$price The filtered price

get_price_html()

Outputs the wholesale price html

public get_price_html(string $price_html, WC_Product $product) : string
Parameters
$price_html : string
$product : WC_Product
Tags
Return values
string

$price_html

get_sale_price()

Filters the product sale price

public get_sale_price(string|float $sale_price, WC_Product $product) : float
Parameters
$sale_price : string|float
$product : WC_Product
Tags
Return values
float

$sale_price

has_price_changed()

Determine whether the product price has changed

public has_price_changed(WC_Product $product) : bool

This usually happens when a plugin alters the price of a product attached to a cart item (e.g. with $cart_item['data']->set_price( $some_price ) ) Excluding this case, we prevent the wholesale price from overriding any changes when the cart is recalculated (i.e. after woocommerce_before_calculate_totals)

Parameters
$product : WC_Product
Tags
Return values
bool

is_on_sale()

Determine whether a product is on sale based on the wholesale role of the user currently logged in

public is_on_sale(bool $onsale, WC_Product $product) : bool
Parameters
$onsale : bool
$product : WC_Product
Tags
Return values
bool

register()

{@inheritdoc}

public register() : mixed
Tags
Return values
mixed

remove_sale_price_filter()

Remove the sale price filter to avoid endless loop within the `woocommerce_product_get_sale_price` filter

public remove_sale_price_filter() : void
Tags
Return values
void

show_variation_prices()

Show variation prices for wholesale always

public show_variation_prices(bool $show, WC_Product_Variable $parent_product, WC_Product $variation_product) : bool
Parameters
$show : bool
$parent_product : WC_Product_Variable
$variation_product : WC_Product
Tags
Return values
bool

update_product()

Clears the product transients

public update_product(int $product_id) : mixed
Parameters
$product_id : int
Tags
Return values
mixed

variation_prices()

Alter the array with the variation prices

public variation_prices(array<string|int, mixed> $prices_array, array<string|int, mixed> $product, bool $for_display) : array<string|int, mixed>
Parameters
$prices_array : array<string|int, mixed>

The array with the variation prices

$product : array<string|int, mixed>

The variable product the variations belong to

$for_display : bool

Whether the prices are for display or not

Tags
Return values
array<string|int, mixed>

variation_prices_hash()

Add a custom price hash for the variation price range cache

public variation_prices_hash(array<string|int, mixed> $price_hash, WC_Product $product, bool $for_display) : array<string|int, mixed>
Parameters
$price_hash : array<string|int, mixed>
$product : WC_Product
$for_display : bool
Tags
Return values
array<string|int, mixed>

$price_hash

disregard_wholesale_pricing()

Determine whether to disregard the wholesale pricing

private disregard_wholesale_pricing(WC_Product $product) : bool
Parameters
$product : WC_Product

The current product.

Tags
since
3.0.9
Return values
bool

Search results