Product_Table extends Plugin_Integration implements Registerable
Product Table Plugin Integration.
Tags
Interfaces, Classes and Traits
- Registerable
Table of Contents
- $plugin_class : string
- The main plugin class to check for existence.
- $plugin_function : string
- The main plugin function to check for existence.
- add_closing_tag() : void
- Add closing div tag for the products loop.
- add_opening_tag() : void
- Add opening div tag for the products loop.
- filter_products_query() : void
- Filter the products query to use WCF found products.
- handle_faceted_search_ajax() : array<string|int, mixed>
- Handle faceted search AJAX requests for Product Table.
- override_posts_per_page() : int
- Override the posts per page to use the rows per page setting from the Product Table.
- override_products_loop() : string
- Override the products loop with the Product Table.
- override_renderer_posts_per_page() : int
- Override the posts per page to use the rows per page setting from the Product Table.
- plugin_is_enabled() : bool
- Check if the plugin is enabled.
- prevent_wcf_product_loop() : bool
- Prevent the WCF product loop from being displayed if the page has a product table shortcode.
- register() : void
- Register the integration.
- reinitialize_product_table() : void
- Reinitialize the product table after the WCF products loop has been rendered.
- sanitize_table_args() : array<string|int, mixed>
- Sanitize table arguments from integrations data.
- set_query_args() : void
- Set the query args for the query.
- table_output() : string
- Modify the table output to include filters.
- cache_product_table_args() : self
- Cache the product table arguments.
- get_product_ids_from_table_args() : array<string|int, mixed>
- Get product IDs from table arguments.
- is_core_page() : bool
- Check if the current page is a core page.
- is_table_lazy_loaded() : bool
- Check if the table is lazy loaded.
- page_has_product_table_shortcode() : bool
- Check if the page has a product table shortcode.
Properties
$plugin_class
The main plugin class to check for existence.
protected
string
$plugin_class
= ''
$plugin_function
The main plugin function to check for existence.
protected
string
$plugin_function
= '\\Barn2\\Plugin\\WC_Product_Table\\wpt'
Methods
add_closing_tag()
Add closing div tag for the products loop.
public
add_closing_tag(object $table) : void
Parameters
- $table : object
-
The table object.
Return values
void —add_opening_tag()
Add opening div tag for the products loop.
public
add_opening_tag() : void
Return values
void —filter_products_query()
Filter the products query to use WCF found products.
public
filter_products_query(array<string|int, mixed> $found_products, Renderer $renderer) : void
Parameters
- $found_products : array<string|int, mixed>
-
Array of found products.
- $renderer : Renderer
-
The renderer instance.
Return values
void —handle_faceted_search_ajax()
Handle faceted search AJAX requests for Product Table.
public
handle_faceted_search_ajax(array<string|int, mixed> $new_args, object $table) : array<string|int, mixed>
Processes the faceted search response from WCF and updates the Product Table query with the filtered products and pagination totals.
Parameters
- $new_args : array<string|int, mixed>
-
The new arguments for the AJAX request.
- $table : object
-
The Product Table instance.
Return values
array<string|int, mixed> —The modified arguments.
override_posts_per_page()
Override the posts per page to use the rows per page setting from the Product Table.
public
override_posts_per_page(int $posts_per_page, Query $query) : int
Parameters
- $posts_per_page : int
-
The posts per page.
- $query : Query
-
The query object.
Return values
int —The posts per page.
override_products_loop()
Override the products loop with the Product Table.
public
override_products_loop(string $output, array<string|int, mixed> $products, Renderer $renderer) : string
Parameters
- $output : string
-
The output to return (null to continue with default rendering)
- $products : array<string|int, mixed>
-
Array of WC_Product objects
- $renderer : Renderer
-
The current renderer instance
Return values
string —The modified output
override_renderer_posts_per_page()
Override the posts per page to use the rows per page setting from the Product Table.
public
override_renderer_posts_per_page(int $posts_per_page, Renderer $renderer) : int
Parameters
- $posts_per_page : int
-
The posts per page.
- $renderer : Renderer
-
The renderer instance.
Return values
int —The posts per page.
plugin_is_enabled()
Check if the plugin is enabled.
public
plugin_is_enabled() : bool
Return values
bool —prevent_wcf_product_loop()
Prevent the WCF product loop from being displayed if the page has a product table shortcode.
public
prevent_wcf_product_loop(bool $override) : bool
Parameters
- $override : bool
-
Whether the WCF product loop should be displayed.
Return values
bool —Whether the WCF product loop should be displayed.
register()
Register the integration.
public
register() : void
Return values
void —reinitialize_product_table()
Reinitialize the product table after the WCF products loop has been rendered.
public
reinitialize_product_table() : void
Attaches a listener to the wcf:products:afterRender event to reinitialize the table.
Intercepts the next AJAX request and adds the faceted_search and faceted_response parameters.
The faceted_search parameter is used to indicate that the search is faceted. The faceted_response parameter is used to pass the response from the WCF products loop.
Return values
void —sanitize_table_args()
Sanitize table arguments from integrations data.
public
sanitize_table_args(array<string|int, mixed> $sanitized, array<string|int, mixed> $integrations) : array<string|int, mixed>
Parameters
- $sanitized : array<string|int, mixed>
-
The sanitized integrations array.
- $integrations : array<string|int, mixed>
-
The raw integrations data.
Return values
array<string|int, mixed> —The sanitized integrations array.
set_query_args()
Set the query args for the query.
public
set_query_args(Query $query) : void
This is used to set the query args for the query, so that the starting point for the filters is related to the context of the table.
This does not apply on the shop page and archive pages.
Parameters
- $query : Query
-
The query object.
Return values
void —table_output()
Modify the table output to include filters.
public
table_output(string $result, string $output, object $table) : string
Parameters
- $result : string
-
The table HTML output.
- $output : string
-
The output type.
- $table : object
-
The table object.
Return values
string —Modified table output.
cache_product_table_args()
Cache the product table arguments.
private
cache_product_table_args(array<string|int, mixed> $args) : self
Arguments are passed along search requests and are used as a way to track customizations necessary for plugins, themes and whatever else may be necessary.
Parameters
- $args : array<string|int, mixed>
-
The product table arguments.
Tags
Return values
self —get_product_ids_from_table_args()
Get product IDs from table arguments.
private
get_product_ids_from_table_args(array<string|int, mixed> $table_args) : array<string|int, mixed>
Parameters
- $table_args : array<string|int, mixed>
-
The table arguments.
Return values
array<string|int, mixed> —Array of product IDs.
is_core_page()
Check if the current page is a core page.
private
is_core_page() : bool
Return values
bool —Whether the current page is a core page.
is_table_lazy_loaded()
Check if the table is lazy loaded.
private
is_table_lazy_loaded(array<string|int, mixed> $args) : bool
Parameters
- $args : array<string|int, mixed>
-
The table arguments.
Return values
bool —Whether the table is lazy loaded.
page_has_product_table_shortcode()
Check if the page has a product table shortcode.
private
page_has_product_table_shortcode() : bool
Return values
bool —Whether the page has a product table shortcode.