Product_Table

Represents a table of WooCommerce products.

This class is responsible for creating the table from the specified parameter and returning the complete table as a Html_Data_Table instance.

The main functions provided are get_table() and get_data().

Tags
author

Barn2 Plugins support@barn2.com

license

GPL-3.0

copyright

Barn2 Media Ltd

Table of Contents

CONTROL_COLUMN_DATA_SOURCE  = 'control'
$args  : mixed
$data_table  : mixed
$hooks  : mixed
$id  : mixed
$query  : mixed
$cache  : mixed
$columns  : mixed
$config_builder  : mixed
$data_added  : mixed
$data_factory  : mixed
$table_initialised  : mixed
__construct()  : mixed
get_data()  : object|array<string|int, mixed>|string
Retrieves the data table containing the list of products based on the specified arguments.
get_table()  : object|array<string|int, mixed>|string
Retrieves the data table containing the list of products based on the arguments supplied on construction.
update()  : mixed
Update the table with new arguments specified in $args. Previously posts data is preserved where possible, to prevent additional DB calls.
add_attributes()  : mixed
add_heading()  : mixed
add_headings()  : mixed
add_product_data()  : mixed
add_products_to_table()  : mixed
Add the products (array of post objects) to the table.
append_bulk_select_checkbox()  : mixed
array_filter_empty_attribute()  : mixed
can_fetch_data()  : mixed
fetch_data()  : mixed
get_row_attributes()  : mixed
json_encode_config()  : mixed
setup_postdata_for_product()  : mixed

Constants

CONTROL_COLUMN_DATA_SOURCE

public mixed CONTROL_COLUMN_DATA_SOURCE = 'control'

Properties

Methods

__construct()

public __construct(mixed $id[, array<string|int, mixed> $args = [] ]) : mixed
Parameters
$id : mixed
$args : array<string|int, mixed> = []
Return values
mixed

get_data()

Retrieves the data table containing the list of products based on the specified arguments.

public get_data([string $output = 'object' ]) : object|array<string|int, mixed>|string

The table returned includes only the table data itself (i.e. the rows), and doesn't include the header, footer, etc.

If the output is 'object' the returned object will be an Html_Data_Table instance. If the output is 'html', the data returned will be a string containing a list of elements, one for each product found. If the output is 'array', the data returned will be an array of rows, one for each product found. if the output is 'json', the data returned will be a JSON-encoded string in the same format as 'array'.

Parameters
$output : string = 'object'

The output type (see description).

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

The product table data in the requested format.

get_table()

Retrieves the data table containing the list of products based on the arguments supplied on construction.

public get_table([string $output = 'object' ]) : object|array<string|int, mixed>|string

The table returned includes the table headings, attributes and data.

If the output is 'object' the returned object is an Html_Data_Table instance. If the output is 'html', the table returned will be a string containing the

element at its root, and include the , and elements. If the output is 'array', the table returned will be an array containing the following keys: 'thead', 'tbody', 'tfoot' and 'attributes'. If the output is 'json', the return value will be a JSON-encoded string in the same format as 'array'.

Parameters
$output : string = 'object'

The output format - object, html, array or json. Default 'object'.

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

The product table in the requested format.

update()

Update the table with new arguments specified in $args. Previously posts data is preserved where possible, to prevent additional DB calls.

public update(array<string|int, mixed> $args) : mixed
Parameters
$args : array<string|int, mixed>

The new args. Does not need to be a complete list (will be merged with current properties)

Return values
mixed

add_attributes()

private add_attributes() : mixed
Return values
mixed

add_heading()

private add_heading(mixed $heading, mixed $attributes, mixed $key) : mixed
Parameters
$heading : mixed
$attributes : mixed
$key : mixed
Return values
mixed

add_headings()

private add_headings() : mixed
Return values
mixed

add_product_data()

private add_product_data(mixed $column, mixed $key, mixed $product) : mixed
Parameters
$column : mixed
$key : mixed
$product : mixed
Return values
mixed

add_products_to_table()

Add the products (array of post objects) to the table.

private add_products_to_table(array<string|int, mixed> $products) : mixed
Parameters
$products : array<string|int, mixed>

An array of WC_Product objects

Return values
mixed

append_bulk_select_checkbox()

private append_bulk_select_checkbox(mixed $heading, mixed $attributes, mixed $key) : mixed
Parameters
$heading : mixed
$attributes : mixed
$key : mixed
Return values
mixed

array_filter_empty_attribute()

private static array_filter_empty_attribute(mixed $value) : mixed
Parameters
$value : mixed
Return values
mixed

can_fetch_data()

private can_fetch_data() : mixed
Return values
mixed

fetch_data()

private fetch_data() : mixed
Return values
mixed

get_row_attributes()

private get_row_attributes(mixed $product) : mixed
Parameters
$product : mixed
Return values
mixed

json_encode_config()

private static json_encode_config(mixed $config) : mixed
Parameters
$config : mixed
Return values
mixed

setup_postdata_for_product()

private setup_postdata_for_product(mixed $product) : mixed
Parameters
$product : mixed
Return values
mixed

Search results