Util

Utility functions for WooCommerce Fast Cart

Tags
author

Barn2 Plugins support@barn2.com

license

GPL-3.0

copyright

Barn2 Media Ltd

Table of Contents

OPTION_NAME  = 'wc_fast_cart_settings'
$settings  : mixed
absfloat()  : float
Returns the absolute value of a sanitized floating point number
color_yiq()  : string
Returns the hexadecimal color code for either white or black, based on which has the highest contrast with a given color
convert_settings_from_wc_format()  : array<string|int, mixed>
Converts 'yes'/'no' string values into boolean true/false
convert_settings_to_wc_format()  : array<string|int, mixed>
Converts boolean true/false into 'yes'/'no' string values
format_rest_error()  : string
Adds plugin name to error string
get_asset_path()  : string
Retreives the absolute disk path of an asset contained in the plugin's assets folder
get_asset_url()  : string
Retreives the absolute url of an asset contained in the plugin's assets folder
get_default_settings()  : array<string|int, mixed>
Returns the default setting values
get_settings()  : array<string|int, mixed>
Returns the combination of current user settings and default values
get_settings_list()  : array<string|int, mixed>
Get WooCommerce compatible list of settings
get_template_path()  : string
Searches for a user defined template file in the theme/wfc, plugin/templates folders, with that priority
get_wc_notices()  : array<string|int, mixed>
Wrapper for wc_get_notices to account for various return formats
load_template()  : mixed
Outputs a user defined template file in the theme/wfc, plugin/templates folders, with that priority
prepare_wizard_fields_for_wc()  : array<string|int, mixed>
Reformats values generated by setup wizard into WC compatible values.

Constants

OPTION_NAME

public mixed OPTION_NAME = 'wc_fast_cart_settings'
Tags

Properties

$settings

private static mixed $settings = null
Tags

Methods

absfloat()

Returns the absolute value of a sanitized floating point number

public static absfloat(mixed $val) : float
Parameters
$val : mixed
Tags
since

v0.1

Return values
float

color_yiq()

Returns the hexadecimal color code for either white or black, based on which has the highest contrast with a given color

public static color_yiq(string $hexcolor) : string
Parameters
$hexcolor : string

a hexadecimal color code to compare contrast levels with, must include '#' at beginning of string

Tags
since

v0.1

Return values
string

convert_settings_from_wc_format()

Converts 'yes'/'no' string values into boolean true/false

public static convert_settings_from_wc_format(array<string|int, mixed> $settings) : array<string|int, mixed>
Parameters
$settings : array<string|int, mixed>
Tags
since

v0.1

Return values
array<string|int, mixed>

convert_settings_to_wc_format()

Converts boolean true/false into 'yes'/'no' string values

public static convert_settings_to_wc_format(array<string|int, mixed> $settings) : array<string|int, mixed>
Parameters
$settings : array<string|int, mixed>
Tags
since

v0.1

Return values
array<string|int, mixed>

format_rest_error()

Adds plugin name to error string

public static format_rest_error(string $error_message) : string
Parameters
$error_message : string

original error message

Tags
since

v0.1

Return values
string

get_asset_path()

Retreives the absolute disk path of an asset contained in the plugin's assets folder

public static get_asset_path([string $path = '' ]) : string
Parameters
$path : string = ''

Default: '' path of asset relative to assets folder

Tags
since

v0.1

Return values
string

get_asset_url()

Retreives the absolute url of an asset contained in the plugin's assets folder

public static get_asset_url([string $path = '' ]) : string
Parameters
$path : string = ''

Default: '' path of asset relative to assets folder

Tags
since

v0.1

Return values
string

get_default_settings()

Returns the default setting values

public static get_default_settings() : array<string|int, mixed>
Tags
since

v0.1

Return values
array<string|int, mixed>

get_settings()

Returns the combination of current user settings and default values

public static get_settings([bool $force_refresh = false ]) : array<string|int, mixed>
Parameters
$force_refresh : bool = false

Setting to false will avoid using settings already in memory

Tags
since

v0.1

Return values
array<string|int, mixed>

get_settings_list()

Get WooCommerce compatible list of settings

public static get_settings_list(mixed $plugin) : array<string|int, mixed>
Parameters
$plugin : mixed
Tags
Return values
array<string|int, mixed>

get_template_path()

Searches for a user defined template file in the theme/wfc, plugin/templates folders, with that priority

public static get_template_path(string $template_name) : string
Parameters
$template_name : string

name of template file, including .php extension

Tags
since

v0.1

Return values
string

the absolute path of the template file

get_wc_notices()

Wrapper for wc_get_notices to account for various return formats

public static get_wc_notices(string $notice_type) : array<string|int, mixed>
Parameters
$notice_type : string

type of notice to return

Tags
since

v0.1

Return values
array<string|int, mixed>

load_template()

Outputs a user defined template file in the theme/wfc, plugin/templates folders, with that priority

public static load_template(string $template_name[, array<string|int, mixed> $args = [] ]) : mixed
Parameters
$template_name : string

name of template file, including .php extension

$args : array<string|int, mixed> = []

pass arbitrary arguments to the template file

Tags
since

v0.1

Return values
mixed

prepare_wizard_fields_for_wc()

Reformats values generated by setup wizard into WC compatible values.

public static prepare_wizard_fields_for_wc(mixed $values) : array<string|int, mixed>
Parameters
$values : mixed
Tags
Return values
array<string|int, mixed>

Search results