WooCommerce Code Reference

WC_Admin_List_Table_Products extends WC_Admin_List_Table
in package

WC_Admin_List_Table_Products Class.

Table of Contents

$list_table_type  : string
Post type.
$object  : object|null
Object being shown on the row.
$cogs_is_enabled  : bool
Caches the value of the "COGS is enabled" flag.
$use_cogs_lookup_column  : bool
Flag indicating if the COGS value column in the product meta lookup table can be used.
__construct()  : mixed
Constructor.
add_custom_query_var()  : array<string|int, mixed>
Query vars for custom searches.
add_sample_product_badge()  : mixed
Add a sample product badge to the product list table.
add_variation_parents_for_shipping_class()  : array<string|int, mixed>
Modifies post query so that it includes parent products whose variations have particular shipping class assigned.
default_hidden_columns()  : array<string|int, mixed>
Adjust which columns are displayed by default.
define_bulk_actions()  : array<string|int, mixed>
Define bulk actions.
define_columns()  : array<string|int, mixed>
Define which columns to show on this screen.
define_sortable_columns()  : array<string|int, mixed>
Define which columns are sortable.
disable_view_mode()  : array<string|int, mixed>
Removes this type from list of post types that support "View Mode" switching.
filter_downloadable_post_clauses()  : array<string|int, mixed>
Filter by type.
filter_stock_status_post_clauses()  : array<string|int, mixed>
Filter by stock status.
filter_virtual_post_clauses()  : array<string|int, mixed>
Filter by type.
handle_bulk_actions()  : string
Handle bulk actions.
list_table_primary_column()  : string
Set list table primary column.
maybe_render_blank_state()  : mixed
Show blank slate.
order_by_cogs_value_asc_post_clauses()  : array<string|int, mixed>
Handle COGS value sorting.
order_by_cogs_value_desc_post_clauses()  : array<string|int, mixed>
Handle COGS value sorting.
order_by_global_unique_id_asc_post_clauses()  : array<string|int, mixed>
Handle global unique ID sorting.
order_by_global_unique_id_desc_post_clauses()  : array<string|int, mixed>
Handle global unique ID sorting.
order_by_price_asc_post_clauses()  : array<string|int, mixed>
Handle numeric price sorting.
order_by_price_desc_post_clauses()  : array<string|int, mixed>
Handle numeric price sorting.
order_by_sku_asc_post_clauses()  : array<string|int, mixed>
Handle sku sorting.
order_by_sku_desc_post_clauses()  : array<string|int, mixed>
Handle sku sorting.
order_search_results()  : array<string|int, mixed>
Prioritize title matches in unsorted product searches.
posts_clauses()  : array<string|int, mixed>
Undocumented function
prime_thumbnail_caches()  : array<string|int, mixed>
Prime featured image caches for product queries to avoid individual queries during rendering.
product_views()  : array<string|int, mixed>
Change views on the edit product screen.
remove_ordering_args()  : array<string|int, mixed>
Remove ordering queries.
render_columns()  : mixed
Render individual columns.
render_products_stock_status_filter()  : mixed
Render the stock status filter for the list table.
request_query()  : array<string|int, mixed>
Handle any filters.
restrict_manage_posts()  : mixed
See if we should render search filters or not.
row_actions()  : array<string|int, mixed>
Set row actions.
search_label()  : string
Change the label when searching products
sku_search()  : string
Search by SKU or ID for products.
define_hidden_columns()  : array<string|int, mixed>
Define which columns are hidden by default.
get_primary_column()  : string
Define primary column.
get_row_actions()  : array<string|int, mixed>
Get row actions to show in the list table.
prepare_row_data()  : mixed
Pre-fetch any data for the row each column has access to it. the_product global is there for bw compat.
query_filters()  : array<string|int, mixed>
Handle any custom filters.
render_blank_state()  : mixed
Render blank state.
render_cogs_value_column()  : mixed
Render column: cost.
render_featured_column()  : mixed
Render column: featured.
render_filters()  : mixed
Render any custom filters and search inputs for the list table.
render_global_unique_id_column()  : mixed
Render column: global_unique_id.
render_is_in_stock_column()  : mixed
Render column: is_in_stock.
render_name_column()  : mixed
Render column: name.
render_price_column()  : mixed
Render column: price.
render_product_cat_column()  : mixed
Render column: product_cat.
render_product_tag_column()  : mixed
Render column: product_tag.
render_products_category_filter()  : mixed
Render the product category filter for the list table.
render_products_type_filter()  : mixed
Render the product type filter for the list table.
render_sku_column()  : mixed
Render column: sku.
render_thumb_column()  : mixed
Render column: thumb.
append_product_sorting_table_join()  : string
Join wc_product_meta_lookup to posts if not already joined.
build_title_match_case_clause()  : string
Build the relevance expression that ranks title matches ahead of the remaining search results.
get_default_search_order()  : string|null
Get the default ordering mode for a product search.
get_search_stopwords()  : array<string|int, string>
Retrieve stopwords used when parsing product search terms.
get_valid_search_terms()  : array<string|int, string>
Remove unsuitable product search terms.
orderby_leads_with()  : bool
Determine whether a clause still leads with the ordering core generated for this view.
parse_search_terms()  : array<string|int, string>
Parse a product search group using WooCommerce search-term rules.

Properties

Methods

add_sample_product_badge()

Add a sample product badge to the product list table.

public add_sample_product_badge(string $column_name, int $post_id) : mixed
Parameters
$column_name : string

Column name.

$post_id : int

Post ID.

Tags
since
8.8.0
deprecated
11.1.0
Return values
mixed —

add_variation_parents_for_shipping_class()

Modifies post query so that it includes parent products whose variations have particular shipping class assigned.

public add_variation_parents_for_shipping_class(array<string|int, mixed> $pieces, WP_Query $wp_query) : array<string|int, mixed>
Parameters
$pieces : array<string|int, mixed>

Array of SELECT statement pieces (from, where, etc).

$wp_query : WP_Query

WP_Query instance.

Return values
array<string|int, mixed> — Array of products, including parents of variations.

default_hidden_columns()

Adjust which columns are displayed by default.

public default_hidden_columns(array<string|int, mixed> $hidden, object $screen) : array<string|int, mixed>
Parameters
$hidden : array<string|int, mixed>

Current hidden columns.

$screen : object

Current screen.

Return values
array<string|int, mixed> —

define_columns()

Define which columns to show on this screen.

public define_columns(array<string|int, mixed> $columns) : array<string|int, mixed>
Parameters
$columns : array<string|int, mixed>

Existing columns.

Return values
array<string|int, mixed> —

define_sortable_columns()

Define which columns are sortable.

public define_sortable_columns(array<string|int, mixed> $columns) : array<string|int, mixed>
Parameters
$columns : array<string|int, mixed>

Existing columns.

Return values
array<string|int, mixed> —

disable_view_mode()

Removes this type from list of post types that support "View Mode" switching.

public disable_view_mode(array<string|int, mixed> $post_types) : array<string|int, mixed>

View mode is seen on posts where you can switch between list or excerpt. Our post types don't support it, so we want to hide the useless UI from the screen options tab.

Parameters
$post_types : array<string|int, mixed>

Array of post types supporting view mode.

Return values
array<string|int, mixed> — Array of post types supporting view mode, without this type.

filter_stock_status_post_clauses()

Filter by stock status.

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

Query args.

Return values
array<string|int, mixed> —

handle_bulk_actions()

Handle bulk actions.

public handle_bulk_actions(string $redirect_to, string $action, array<string|int, mixed> $ids) : string
Parameters
$redirect_to : string

URL to redirect to.

$action : string

Action name.

$ids : array<string|int, mixed>

List of ids.

Return values
string —

order_by_cogs_value_asc_post_clauses()

Handle COGS value sorting.

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

Query args.

Return values
array<string|int, mixed> —

order_by_cogs_value_desc_post_clauses()

Handle COGS value sorting.

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

Query args.

Return values
array<string|int, mixed> —

order_by_global_unique_id_asc_post_clauses()

Handle global unique ID sorting.

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

Query args.

Return values
array<string|int, mixed> —

order_by_global_unique_id_desc_post_clauses()

Handle global unique ID sorting.

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

Query args.

Return values
array<string|int, mixed> —

order_by_price_asc_post_clauses()

Handle numeric price sorting.

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

Query args.

Return values
array<string|int, mixed> —

order_by_price_desc_post_clauses()

Handle numeric price sorting.

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

Query args.

Return values
array<string|int, mixed> —

order_search_results()

Prioritize title matches in unsorted product searches.

public order_search_results(array<string|int, mixed> $clauses, WP_Query $query) : array<string|int, mixed>

Runs on posts_clauses rather than posts_orderby so that every posts_orderby callback, at any priority, still observes the ORDER BY clause core generated. Reading it that late means it may already carry third-party ordering, so orderby_leads_with() decides whether ranking still leads.

Parameters
$clauses : array<string|int, mixed>

Array of SELECT statement pieces (from, where, orderby, etc).

$query : WP_Query

WP_Query instance.

Tags
since
11.1.0
Return values
array<string|int, mixed> —

posts_clauses()

Undocumented function

public posts_clauses(array<string|int, mixed> $args, WP_Query $query) : array<string|int, mixed>
Parameters
$args : array<string|int, mixed>

Array of SELECT statement pieces (from, where, etc).

$query : WP_Query

WP_Query instance.

Return values
array<string|int, mixed> —

prime_thumbnail_caches()

Prime featured image caches for product queries to avoid individual queries during rendering.

public prime_thumbnail_caches(array<string|int, WP_Post> $posts, WP_Query $query) : array<string|int, mixed>
Parameters
$posts : array<string|int, WP_Post>

Posts from WP Query.

$query : WP_Query

Current query.

Tags
since
10.9.0
Return values
array<string|int, mixed> —

remove_ordering_args()

Remove ordering queries.

public remove_ordering_args([array<string|int, mixed> $posts = array() ]) : array<string|int, mixed>
Parameters
$posts : array<string|int, mixed> = array()

Posts array, keeping this for backwards compatibility defaulting to empty array.

Return values
array<string|int, mixed> —

row_actions()

Set row actions.

public row_actions(array<string|int, mixed> $actions, WP_Post $post) : array<string|int, mixed>
Parameters
$actions : array<string|int, mixed>

Array of actions.

$post : WP_Post

Current post object.

Return values
array<string|int, mixed> —

get_row_actions()

Get row actions to show in the list table.

protected get_row_actions(array<string|int, mixed> $actions, WP_Post $post) : array<string|int, mixed>
Parameters
$actions : array<string|int, mixed>

Array of actions.

$post : WP_Post

Current post object.

Return values
array<string|int, mixed> —

build_title_match_case_clause()

Build the relevance expression that ranks title matches ahead of the remaining search results.

private build_title_match_case_clause(string $search_term) : string
Parameters
$search_term : string

Search term the product matcher already ran against.

Tags
since
11.1.0
Return values
string — CASE expression, or an empty string when the term yields no title predicates.

get_default_search_order()

Get the default ordering mode for a product search.

private get_default_search_order(array<string|int, mixed> $query_vars) : string|null
Parameters
$query_vars : array<string|int, mixed>

Query variables.

Return values
string|null —

get_valid_search_terms()

Remove unsuitable product search terms.

private get_valid_search_terms(array<string|int, string> $terms) : array<string|int, string>

Mirrors WP_Query::get_search_terms(), including its stopword and single-character rules.

Parameters
$terms : array<string|int, string>

Search terms.

Return values
array<string|int, string> —

orderby_leads_with()

Determine whether a clause still leads with the ordering core generated for this view.

private orderby_leads_with(string $orderby, string $core_orderby) : bool

A third party that appends a tiebreak leaves core's ordering in charge of the primary sort, so ranking can still lead. One that prepends or replaces has taken the primary sort over, and ranking defers to it. Only a comma may follow the core clause, so a longer token that merely starts the same way is not mistaken for it.

Parameters
$orderby : string

Clause observed on the query.

$core_orderby : string

Clause core generated for this view.

Tags
since
11.1.0
Return values
bool —

parse_search_terms()

Parse a product search group using WooCommerce search-term rules.

private parse_search_terms(string $search_group) : array<string|int, string>
Parameters
$search_group : string

Search group without OR separators.

Return values
array<string|int, string> —