\Barn2\Plugin\WC_Product_TableProduct_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().

Summary

Methods
Properties
Constants
__construct()
get_table()
get_data()
update()
$id
$args
$query
$hooks
$data_table
CONTROL_COLUMN_DATA_SOURCE
No protected methods found
No protected properties found
N/A
fetch_data()
can_fetch_data()
add_products_to_table()
add_product_data()
add_attributes()
add_headings()
add_heading()
get_row_attributes()
setup_postdata_for_product()
array_filter_empty_attribute()
json_encode_config()
$columns
$data_factory
$config_builder
$cache
$table_initialised
$data_added
N/A

Constants

CONTROL_COLUMN_DATA_SOURCE

CONTROL_COLUMN_DATA_SOURCE ='control'

Properties

$id

$id :

Type

$args

$args :

Type

$query

$query :

Type

$hooks

$hooks :

Type

$data_table

$data_table :

Type

$columns

$columns :

Type

$data_factory

$data_factory :

Type

$config_builder

$config_builder :

Type

$cache

$cache :

Type

$table_initialised

$table_initialised :

Type

$data_added

$data_added :

Type

Methods

__construct()

__construct(  $id,  $args = array())

Parameters

$id
$args

get_table()

get_table(string  $output = 'object'): object|array|string

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

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

string $output

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

Returns

object|array|string —

The product table in the requested format.

get_data()

get_data(  $output = 'object'): object|array|string

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

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

Returns

object|array|string —

The product table data in the requested format.

update()

update(array  $new_args)

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

Parameters

array $new_args

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

fetch_data()

fetch_data()

can_fetch_data()

can_fetch_data()

add_products_to_table()

add_products_to_table(array  $products)

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

Parameters

array $products

An array of WC_Product objects

add_product_data()

add_product_data(  $column,  $key,  $product)

Parameters

$column
$key
$product

add_attributes()

add_attributes()

add_headings()

add_headings()

add_heading()

add_heading(  $heading,  $attributes,  $key)

Parameters

$heading
$attributes
$key

get_row_attributes()

get_row_attributes(  $product)

Parameters

$product

setup_postdata_for_product()

setup_postdata_for_product(  $product)

Parameters

$product

array_filter_empty_attribute()

array_filter_empty_attribute(  $value)

Parameters

$value

json_encode_config()

json_encode_config(  $config)

Parameters

$config