Products implements Registerable

Provides functionality for the single product page.

Tags
author

Barn2 Plugins support@barn2.com

license

GPL-3.0

copyright

Barn2 Media Ltd

Interfaces, Classes and Traits

Registerable

Table of Contents

display_possible_discounts()  : void
Display possible discounts for the current product.
generate_grouped_sale_price()  : string
Generate the sale price for grouped products.
get_discount_for_product()  : Discount|null
Get the top relevant discount for the product.
get_elegible_discounts_for_product()  : array<string|int, mixed>
Get discounts that are elegible for the product.
get_elegible_simple_discounts_for_product()  : array<string|int, mixed>
Get simple discounts that are elegible for the product.
get_first_discount_type_for_product()  : Type
Get the first discount type for the current product.
get_product_price()  : string
Wrapper function around the $product->get_price() method that allows us to override the price for products where necessary via a filter.
maybe_hide_sale_badge()  : string
Maybe Hide the sale badge for products where a simple discount is applicable.
product_has_multiple_discounts()  : bool
Determine whether the current product has multiple discounts.
register()  : void
render_product_content()  : void
Reder the content for the single product page.
render_product_content_own_hook()  : void
Reder the content for the single product page.
set_is_on_sale()  : bool
Set whether the product is on sale for products where a simple discount is applicable.
set_simple_sale_price()  : string
Set the sale price for products where a simple discount is applicable.

Methods

display_possible_discounts()

Display possible discounts for the current product.

public display_possible_discounts() : void
Return values
void

generate_grouped_sale_price()

Generate the sale price for grouped products.

public generate_grouped_sale_price(string $price_html, WC_Product $product, Discount $discount) : string
Parameters
$price_html : string

The price HTML.

$product : WC_Product

The product.

$discount : Discount

The discount.

Return values
string

get_discount_for_product()

Get the top relevant discount for the product.

public get_discount_for_product(int $product_id) : Discount|null
Parameters
$product_id : int

The product ID.

Return values
Discount|null

The discount.

get_elegible_discounts_for_product()

Get discounts that are elegible for the product.

public get_elegible_discounts_for_product(int $product_id) : array<string|int, mixed>
Parameters
$product_id : int

The product ID.

Return values
array<string|int, mixed>

The discounts.

get_elegible_simple_discounts_for_product()

Get simple discounts that are elegible for the product.

public get_elegible_simple_discounts_for_product(WC_Product $product) : array<string|int, mixed>
Parameters
$product : WC_Product

The product.

Return values
array<string|int, mixed>

The discounts.

get_first_discount_type_for_product()

Get the first discount type for the current product.

public get_first_discount_type_for_product(array<string|int, mixed> $discounts) : Type
Parameters
$discounts : array<string|int, mixed>

The discounts.

Return values
Type

get_product_price()

Wrapper function around the $product->get_price() method that allows us to override the price for products where necessary via a filter.

public static get_product_price(WC_Product $product[, string $context = 'view' ]) : string

This is used to ensure that the correct price is retrieved if we're working with other plugins.

For example, this is needed when working with WWP.

Parameters
$product : WC_Product

The product.

$context : string = 'view'

The context. Defaults to 'view'. Accepts 'view' and 'edit'.

Return values
string

maybe_hide_sale_badge()

Maybe Hide the sale badge for products where a simple discount is applicable.

public maybe_hide_sale_badge(string $content, string $post, WC_Product $product) : string
Parameters
$content : string

The content.

$post : string

The post.

$product : WC_Product

The product.

Return values
string

The post.

product_has_multiple_discounts()

Determine whether the current product has multiple discounts.

public product_has_multiple_discounts(array<string|int, mixed> $discounts) : bool
Parameters
$discounts : array<string|int, mixed>
Return values
bool

register()

public register() : void
Tags
inheritdoc
Return values
void

render_product_content()

Reder the content for the single product page.

public render_product_content() : void
Return values
void

render_product_content_own_hook()

Reder the content for the single product page.

public render_product_content_own_hook() : void
Return values
void

set_is_on_sale()

Set whether the product is on sale for products where a simple discount is applicable.

public set_is_on_sale(bool $on_sale, WC_Product $product) : bool
Parameters
$on_sale : bool

Whether the product is on sale.

$product : WC_Product

The product.

Return values
bool

Whether the product is on sale.

set_simple_sale_price()

Set the sale price for products where a simple discount is applicable.

public set_simple_sale_price(string $price_html, WC_Product $product) : string
Parameters
$price_html : string

The price HTML.

$product : WC_Product

The product.

Return values
string

The price HTML.

Search results