Product_Options implements Registerable

Integrates with Product Options.

Tags
author

Barn2 Plugins support@barn2.com

license

GPL-3.0

copyright

Barn2 Media Ltd

Interfaces, Classes and Traits

Registerable

Table of Contents

$cart_discounted_products  : array<string|int, mixed>
Array of cart discounted products.
display_discounted_price_in_cart()  : string
Display the discounted price in the cart.
get_tracked_cart_item_data()  : array<string|int, mixed>
Get the tracked cart item data.
has_cart_item_discounted()  : bool
Check if a cart item is discounted.
register()  : mixed
retrieve_discounted_price()  : float
Retrieve the discounted price for the product in the WPO container.
show_total_discount_cart_checkout()  : void
Show the total discount amount in the cart and checkout.
track_cart_item_data()  : void
Track cart item data.
track_discounted_cart_products()  : self
Track discounted products in the cart.

Properties

$cart_discounted_products

Array of cart discounted products.

public array<string|int, mixed> $cart_discounted_products = []

Methods

display_discounted_price_in_cart()

Display the discounted price in the cart.

public display_discounted_price_in_cart(string $price, array<string|int, mixed> $values, string $cart_item_key) : string
Parameters
$price : string

The price.

$values : array<string|int, mixed>

The cart item values.

$cart_item_key : string

The cart item key.

Return values
string

get_tracked_cart_item_data()

Get the tracked cart item data.

public get_tracked_cart_item_data(string $cart_item_key) : array<string|int, mixed>
Parameters
$cart_item_key : string

The cart item key.

Return values
array<string|int, mixed>

has_cart_item_discounted()

Check if a cart item is discounted.

public has_cart_item_discounted(string $cart_item_key) : bool
Parameters
$cart_item_key : string

The cart item key.

Return values
bool

register()

public register() : mixed
Tags
inheritdoc
Return values
mixed

retrieve_discounted_price()

Retrieve the discounted price for the product in the WPO container.

public retrieve_discounted_price(string $price, WC_Product $product) : float
Parameters
$price : string

The price.

$product : WC_Product

The product.

Return values
float

show_total_discount_cart_checkout()

Show the total discount amount in the cart and checkout.

public show_total_discount_cart_checkout() : void

This is needed because the total discount amount is not calculated correctly when Product Options is active.

Return values
void

track_cart_item_data()

Track cart item data.

public track_cart_item_data(array<string|int, mixed> $cart_item, float $original_price, float $new_price) : void
Parameters
$cart_item : array<string|int, mixed>

The cart item.

$original_price : float

The original price.

$new_price : float

The new price.

Return values
void

track_discounted_cart_products()

Track discounted products in the cart.

public track_discounted_cart_products(string $cart_item_key, array<string|int, mixed> $cart_item_data) : self

This is needed because the price of a product is modified by Product Options.

But we need to know the original price of the product to display the appropriate crossed out price in the cart.

Parameters
$cart_item_key : string

The cart item key.

$cart_item_data : array<string|int, mixed>

The cart item data.

Return values
self

Search results