Util

Utility

Tags
author

Barn2 Plugins support@barn2.com

license

GPL-3.0

copyright

Barn2 Media Ltd

Table of Contents

format_date_diff()  : string
Format the difference between two dates.
format_stock_status_label()  : string
Adjust the label of a stock status accordingly.
get_db_version()  : mixed
get_formatted_wc_stock_statuses_list()  : array<string|int, mixed>
Loop through stock statuses and format the label, then return the formatted array.
get_global_lead_time()  : string|array<string|int, mixed>
Retrieve the proper lead time content based on the global settings.
get_global_lead_time_by_stock_status()  : string|array<string|int, mixed>
The global lead time by using the product's stock status.
get_global_lead_time_date()  : string
Get the global lead time date (timestamp).
get_global_lead_time_format()  : string
Get the global lead time format.
get_global_lead_time_format_by_status()  : string
Retrieve the globally configured lead time format by stock status.
get_global_lead_time_prefix()  : string
Get the global lead time prefix.
get_global_lead_time_prefix_by_stock_status()  : string
Retrieve the globally configured lead time prefix by stock status.
get_global_lead_time_text()  : string
Get the global lead time text.
get_lead_time_by_term_with_stock_status()  : array<string|int, mixed>
Get lead time details using the term and stock status of a product.
get_lead_time_date_by_stock_status()  : string
Get the lead time date of a product by it's stock status.
get_lead_time_format_by_stock_status()  : string
Retrieve lead time format of a product by it's stock status.
get_lead_time_prefix()  : string
Get the lead time prefix.
get_lead_time_text_by_stock_status()  : string
Get the lead time text of a product by it's stock status.
get_product_lead_time_format()  : string
Get the format of the lead time that has been selected for the product.
get_time_wording()  : string|bool
Get the singular or plural word for a specific time unit.
get_variation_key()  : mixed
is_visible()  : bool
Determine if lead time should be visible on the product.
per_stock_enabled()  : bool
Determine if the per stock status option is enabled.
round_time()  : DateTimeInterface
Round a given DateTime by a specific unit.
should_date_display()  : bool
Determine if the given date is in the past.
timestamp_to_date()  : string
Convert timestamp to the date format used in the admin panel for the date picker.

Methods

format_date_diff()

Format the difference between two dates.

public static format_date_diff(DateTime $start[, DateTime $end = null ]) : string
Parameters
$start : DateTime
$end : DateTime = null
Return values
string

format_stock_status_label()

Adjust the label of a stock status accordingly.

public static format_stock_status_label(string $state, string $label) : string
Parameters
$state : string
$label : string
Return values
string

get_db_version()

public static get_db_version() : mixed
Return values
mixed

get_formatted_wc_stock_statuses_list()

Loop through stock statuses and format the label, then return the formatted array.

public static get_formatted_wc_stock_statuses_list() : array<string|int, mixed>
Return values
array<string|int, mixed>

get_global_lead_time()

Retrieve the proper lead time content based on the global settings.

public static get_global_lead_time() : string|array<string|int, mixed>

If it's an array, it means the lead time format is dynamic and a timestamp will be returned too.

Return values
string|array<string|int, mixed>

get_global_lead_time_by_stock_status()

The global lead time by using the product's stock status.

public static get_global_lead_time_by_stock_status(WC_Product $product) : string|array<string|int, mixed>

Returns an array when the global lead time format for the specified status is set to dynamic.

Parameters
$product : WC_Product
Return values
string|array<string|int, mixed>

get_global_lead_time_date()

Get the global lead time date (timestamp).

public static get_global_lead_time_date() : string
Return values
string

get_global_lead_time_format()

Get the global lead time format.

public static get_global_lead_time_format() : string

Either dynamic or static.

Return values
string

get_global_lead_time_format_by_status()

Retrieve the globally configured lead time format by stock status.

public static get_global_lead_time_format_by_status(string $status) : string
Parameters
$status : string
Return values
string

get_global_lead_time_prefix()

Get the global lead time prefix.

public static get_global_lead_time_prefix() : string
Return values
string

get_global_lead_time_prefix_by_stock_status()

Retrieve the globally configured lead time prefix by stock status.

public static get_global_lead_time_prefix_by_stock_status(string $status) : string
Parameters
$status : string
Return values
string

get_global_lead_time_text()

Get the global lead time text.

public static get_global_lead_time_text() : string
Return values
string

get_lead_time_by_term_with_stock_status()

Get lead time details using the term and stock status of a product.

public static get_lead_time_by_term_with_stock_status(object $term, object $product) : array<string|int, mixed>
Parameters
$term : object
$product : object
Return values
array<string|int, mixed>

get_lead_time_date_by_stock_status()

Get the lead time date of a product by it's stock status.

public static get_lead_time_date_by_stock_status(WC_Product $product) : string
Parameters
$product : WC_Product
Return values
string

get_lead_time_format_by_stock_status()

Retrieve lead time format of a product by it's stock status.

public static get_lead_time_format_by_stock_status(WC_Product $product) : string
Parameters
$product : WC_Product
Return values
string

get_lead_time_prefix()

Get the lead time prefix.

public static get_lead_time_prefix([WC_Product|bool $product = false ]) : string

If a product is provided and the dynamic stock status option is enabled, try retrieve the prefix by using the stock status id.

Parameters
$product : WC_Product|bool = false
Return values
string

get_lead_time_text_by_stock_status()

Get the lead time text of a product by it's stock status.

public static get_lead_time_text_by_stock_status(WC_Product $product) : string
Parameters
$product : WC_Product
Return values
string

get_product_lead_time_format()

Get the format of the lead time that has been selected for the product.

public static get_product_lead_time_format(WC_Product $product) : string
Parameters
$product : WC_Product
Return values
string

get_time_wording()

Get the singular or plural word for a specific time unit.

public static get_time_wording(int $unit, string $thing) : string|bool
Parameters
$unit : int

how many days/months/years we're counting - only days and months are checked for now.

$thing : string

the thing we need to get, months or days.

Return values
string|bool

get_variation_key()

public static get_variation_key() : mixed
Return values
mixed

is_visible()

Determine if lead time should be visible on the product.

public static is_visible(WC_Product $product) : bool
Parameters
$product : WC_Product
Return values
bool

per_stock_enabled()

Determine if the per stock status option is enabled.

public static per_stock_enabled() : bool
Return values
bool

round_time()

Round a given DateTime by a specific unit.

public static round_time(DateTimeInterface $datetime[, int $precision = 1 ][, string $unit = 's' ], int $calc) : DateTimeInterface
Parameters
$datetime : DateTimeInterface
$precision : int = 1
$unit : string = 's'
$calc : int
Return values
DateTimeInterface

should_date_display()

Determine if the given date is in the past.

public static should_date_display(string $timestamp) : bool
Parameters
$timestamp : string
Return values
bool

timestamp_to_date()

Convert timestamp to the date format used in the admin panel for the date picker.

public static timestamp_to_date(string $timestamp[, bool $use_wp_format = false ][, bool $relative = true ]) : string
Parameters
$timestamp : string
$use_wp_format : bool = false

whether or not we should use the date format

$relative : bool = true

whether or not the returned date should be relative (eg: in 5 days)

Return values
string

Search results