Text_Labels extends Checkboxes

Radios field class.

Tags
author

Barn2 Plugins support@barn2.com

license

GPL-3.0

copyright

Barn2 Media Ltd

Table of Contents

$choice_char  : array<string|int, mixed>
The choice character setting.
$choice_qty  : array<string|int, mixed>
The choice quantity setting.
$equal_pricing  : bool
Whether all choices have equal pricing.
$has_conditional_logic  : bool
Whether the field has conditional logic.
$has_user_value  : bool
Whether the field has a user-defined value.
$is_display_field  : bool
Whether the field is for display only.
$option  : mixed
$product  : mixed
$stores_multiple_values  : bool
Whether the field supports multiple values (e.g checkboxes).
$supports_multiple_values  : bool
Whether the field supports multiple values (e.g checkboxes, radios, select).
$type  : mixed
$used_settings  : array<string|int, mixed>
An array of settings being used by the field.
__construct()  : mixed
Constructor.
__set()  : void
The set magic method.
get_cart_item_data()  : array<string|int, mixed>
Retrieves the cart item data for the selected value(s) of the field.
get_choice_formula_value()  : string
Get the formula value associated with a choice of the field.
get_conditional_logic_config()  : object|null
Get the field conditional logic config.
get_id()  : string
Get the field id.
get_product()  : WC_Product
Get the product for the field.
get_setting()  : string|array<string|int, mixed>|null
Get the value of a specific field setting.
get_settings()  : array<string|int, mixed>|null
Get the array with the field settings.
get_type()  : string
Get the field type.
has_conditional_logic()  : bool
Whether the field has conditional logic.
has_user_value()  : bool
Whether the field has a user inputted value.
is_required()  : bool
Whether the field is required.
render()  : void
Render the HTML for the field.
sanitize()  : mixed
Sanitize the field input value.
stores_multiple_values()  : bool
Whether the field stores multiple values.
validate()  : WP_Error|true
Validate the filed value.
get_attachment_image_sizes()  : string
Get the `sizes` attribute for the image element.
get_choice_for_value()  : array<string|int, mixed>|null
Retrieves the choice from the option DB based on the user value provided.
get_choice_image()  : string
get_choice_image_html()  : string
Get the choice image HTML markup
get_choice_pricing_attributes()  : string
Gets the data attributes to handle JS pricing calculation.
get_choice_pricing_string()  : string
Retrieves the pricing string for a choice
get_field_attributes()  : string
Gets the data attributes to handle conditional logic visibilities.
get_field_class()  : string
Gets the CSS class for the field.
get_image_data()  : string
Return the `data-image` attribute of the image button.
get_image_srcset()  : string
Get the srcset attribute for the image.
get_input_id()  : string
Gets the id attribute for the field input.
get_input_name()  : string
Gets the name attribute for the field input.
get_label()  : string
Get the label for the field or its choices.
get_pricing_attributes()  : array<string|int, mixed>
Retrieves top level pricing attributes for the field.
get_required_symbol()  : mixed
has_choice_images()  : bool
has_display_prerequisites()  : bool
Determines whether the option has enough data to display.
is_update_main_image_enable()  : bool
Whether the option has the "Update main image" setting enabled.
render_choice_character_limits_label()  : void
Gets the label for choice character limits if applicable.
render_choice_quantity_limits_label()  : void
Gets the label for choice quantity limits if applicable.
render_description()  : void
Render the HTML for the field description.
render_field_wrap_close()  : void
Renders the field wrap closing tag.
render_field_wrap_open()  : void
Renders the field wrap.
render_option_name()  : void
Render the HTML for the field label.
get_checkbox_group_class()  : string
Get the class for the checkbox group.
get_edit_option_link()  : mixed
init_conditional_logic()  : mixed
Determine whether the field has conditional logic.
render_checkboxes()  : void
Render the HTML for the field checkboxes.
render_labels()  : void
Render the HTML for the field checkboxes.

Properties

$choice_char

The choice character setting.

protected array<string|int, mixed> $choice_char
Tags

$choice_qty

The choice quantity setting.

protected array<string|int, mixed> $choice_qty
Tags

$equal_pricing

Whether all choices have equal pricing.

protected bool $equal_pricing
Tags

$has_conditional_logic

Whether the field has conditional logic.

protected bool $has_conditional_logic = false
Tags

$has_user_value

Whether the field has a user-defined value.

protected bool $has_user_value = false
Tags

$is_display_field

Whether the field is for display only.

protected bool $is_display_field = false
Tags

$stores_multiple_values

Whether the field supports multiple values (e.g checkboxes).

protected bool $stores_multiple_values = true
Tags

$supports_multiple_values

Whether the field supports multiple values (e.g checkboxes, radios, select).

protected bool $supports_multiple_values = true
Tags

$used_settings

An array of settings being used by the field.

protected array<string|int, mixed> $used_settings = []
Tags

Methods

__construct()

Constructor.

public __construct(mixed $option, WC_Product $product) : mixed
Parameters
$option : mixed
$product : WC_Product
Tags
Return values
mixed

get_cart_item_data()

Retrieves the cart item data for the selected value(s) of the field.

public get_cart_item_data(mixed $value, WC_Product $product, int $quantity, array<string|int, mixed> $options) : array<string|int, mixed>
Parameters
$value : mixed
$product : WC_Product
$quantity : int
$options : array<string|int, mixed>
Tags
Return values
array<string|int, mixed>

get_choice_formula_value()

Get the formula value associated with a choice of the field.

public get_choice_formula_value(int $index) : string
Parameters
$index : int

The index of the choice

Tags
Return values
string

get_conditional_logic_config()

Get the field conditional logic config.

public get_conditional_logic_config() : object|null
Tags
Return values
object|null

get_id()

Get the field id.

public get_id() : string
Tags
Return values
string

get_product()

Get the product for the field.

public get_product() : WC_Product
Tags
Return values
WC_Product

get_setting()

Get the value of a specific field setting.

public get_setting(string $setting_name) : string|array<string|int, mixed>|null
Parameters
$setting_name : string

The key of the setting to retrieve.

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

get_settings()

Get the array with the field settings.

public get_settings() : array<string|int, mixed>|null
Tags
Return values
array<string|int, mixed>|null

get_type()

Get the field type.

public get_type() : string
Tags
Return values
string

has_conditional_logic()

Whether the field has conditional logic.

public has_conditional_logic() : bool
Return values
bool

has_user_value()

Whether the field has a user inputted value.

public has_user_value() : bool
Return values
bool

is_required()

Whether the field is required.

public is_required() : bool
Tags
Return values
bool

render()

Render the HTML for the field.

public render() : void
Tags
Return values
void

sanitize()

Sanitize the field input value.

public sanitize(mixed $value) : mixed
Parameters
$value : mixed
Tags
Return values
mixed

stores_multiple_values()

Whether the field stores multiple values.

public stores_multiple_values() : bool
Return values
bool

validate()

Validate the filed value.

public validate(mixed $value, array<string|int, mixed> $option_data) : WP_Error|true
Parameters
$value : mixed
$option_data : array<string|int, mixed>
Tags
Return values
WP_Error|true

get_attachment_image_sizes()

Get the `sizes` attribute for the image element.

protected get_attachment_image_sizes(string|int $attachment_id, mixed $width) : string
Parameters
$attachment_id : string|int

The ID of the image attachment.

$width : mixed
Tags
since
1.6.4
Return values
string

get_choice_for_value()

Retrieves the choice from the option DB based on the user value provided.

protected get_choice_for_value(mixed $value) : array<string|int, mixed>|null
Parameters
$value : mixed
Tags
Return values
array<string|int, mixed>|null

get_choice_image()

protected get_choice_image(mixed $index) : string
Parameters
$index : mixed
Tags
Return values
string

get_choice_image_html()

Get the choice image HTML markup

protected get_choice_image_html(mixed $index) : string
Parameters
$index : mixed
Tags
Return values
string

get_choice_pricing_attributes()

Gets the data attributes to handle JS pricing calculation.

protected get_choice_pricing_attributes([array<string|int, mixed> $choice = [] ]) : string
Parameters
$choice : array<string|int, mixed> = []
Tags
Return values
string

get_choice_pricing_string()

Retrieves the pricing string for a choice

protected get_choice_pricing_string([array<string|int, mixed> $choice = [] ][, mixed $skip_parenthesis = true ]) : string
Parameters
$choice : array<string|int, mixed> = []
$skip_parenthesis : mixed = true
Tags
Return values
string

get_field_attributes()

Gets the data attributes to handle conditional logic visibilities.

protected get_field_attributes() : string
Tags
Return values
string

get_field_class()

Gets the CSS class for the field.

protected get_field_class() : string
Tags
Return values
string

get_image_data()

Return the `data-image` attribute of the image button.

protected get_image_data(string|int $attachment_id) : string

The attribute contains the image data in JSON format as returned by the wc_get_product_attachment_props function.

Parameters
$attachment_id : string|int

The ID of the image attachment.

Tags
since
1.6.4
Return values
string

get_image_srcset()

Get the srcset attribute for the image.

protected get_image_srcset(int $image_id, mixed $size) : string
Parameters
$image_id : int
$size : mixed
Tags
Return values
string

get_input_id()

Gets the id attribute for the field input.

protected get_input_id() : string
Tags
Return values
string

get_input_name()

Gets the name attribute for the field input.

protected get_input_name() : string
Tags
Return values
string

get_label()

Get the label for the field or its choices.

protected get_label(int $index[, mixed $skip_filters = false ]) : string

The $index parameter is used to get the label for a specific choice. For single-choice fields, the $index can be omitted.

Parameters
$index : int

The index of the choice (or 0 for single-choice fields)

$skip_filters : mixed = false
Tags
Return values
string

get_pricing_attributes()

Retrieves top level pricing attributes for the field.

protected get_pricing_attributes() : array<string|int, mixed>
Tags
Return values
array<string|int, mixed>

get_required_symbol()

protected get_required_symbol() : mixed
Tags
Return values
mixed

has_choice_images()

protected has_choice_images() : bool
Tags
Return values
bool

has_display_prerequisites()

Determines whether the option has enough data to display.

protected has_display_prerequisites() : bool
Tags
Return values
bool

is_update_main_image_enable()

Whether the option has the "Update main image" setting enabled.

protected is_update_main_image_enable() : bool
Tags
since
1.6.4
Return values
bool

render_choice_character_limits_label()

Gets the label for choice character limits if applicable.

protected render_choice_character_limits_label() : void
Tags
Return values
void

render_choice_quantity_limits_label()

Gets the label for choice quantity limits if applicable.

protected render_choice_quantity_limits_label() : void
Tags
Return values
void

render_description()

Render the HTML for the field description.

protected render_description() : void
Tags
Return values
void

render_field_wrap_close()

Renders the field wrap closing tag.

protected render_field_wrap_close() : void
Tags
Return values
void

render_field_wrap_open()

Renders the field wrap.

protected render_field_wrap_open() : void
Tags
Return values
void

render_option_name()

Render the HTML for the field label.

protected render_option_name() : void
Tags
Return values
void

get_checkbox_group_class()

Get the class for the checkbox group.

private get_checkbox_group_class() : string
Tags
Return values
string
private get_edit_option_link() : mixed
Tags
Return values
mixed

init_conditional_logic()

Determine whether the field has conditional logic.

private init_conditional_logic() : mixed
Tags
Return values
mixed

render_checkboxes()

Render the HTML for the field checkboxes.

private render_checkboxes() : void
Tags
Return values
void

render_labels()

Render the HTML for the field checkboxes.

private render_labels() : void
Tags
Return values
void

Search results