Display implements Registerable, JsonSerializable

Handles the display of several elements of the plugin.

Interfaces, Classes and Traits

Registerable
JsonSerializable

Table of Contents

IDENTIFIER  = 'wcf-frontend'
$enqueued  : mixed
$tag_inserted  : int
The number of times the loop tag has been inserted.
add_active_filters()  : void
Add entry DIV where the active filters list is displayed.
add_closing_template_tag()  : void
Add inline comment to wrap the end of the loop.
add_infinite_loading()  : void
Add entry DIV where the pagination is displayed.
add_loading_holder()  : void
Add the loading state holder into the footer.
add_mobile_drawer()  : void
Add entry DIV, where the mobile drawer will be attached to.
add_shop_filters()  : void
When a filter group is selected, automatically display it within the shop page.
add_sorting_bar()  : void
Add our custom sorting and results bar.
add_template_tag()  : void
Add inline comment to wrap the loop.
assets()  : void
Load the assets required for the frontend.
close_hider()  : void
Close the wrapper opened above.
filter_templates()  : string
Filter specific default WC templates only when our frontend scripts are enqueued.
get_backup_pagination()  : string
Get the backup pagination template.
get_design_settings()  : array<string|int, mixed>
Get the design configuration of the plugin.
get_initial_products_count()  : string
Get the unfiltered initial products count.
get_language_vars()  : array<string|int, mixed>
Returns a list of language variables that are used in the frontend.
get_products_per_page()  : string|int
Get the number of posts per page.
get_search_base_url()  : string|false
Get the current search base URL.
get_tag_inserted()  : int
Get the number of times the loop tag has been inserted.
increase_tag_inserted()  : self
Increase the number of times the loop tag has been inserted.
is_product_post_type()  : bool
Determine if the query is querying for products.
is_product_taxonomy_page()  : bool
Determine if we're on a product taxonomy page.
jsonSerialize()  : array<string|int, mixed>
Use the JsonSerializable interface to add inline json on the frontend.
load_translation()  : void
Load translations for assets
open_hider()  : void
Wrap the content into a custom div so that we can hide it via css.
register()  : void
Hook into WP.
shortcode()  : string
Registers the renderer shortcode.
prepare_json_for_shortcode()  : array<string|int, mixed>
Prepare the filters collection to be used via javascript from the shortcode.

Constants

IDENTIFIER

public mixed IDENTIFIER = 'wcf-frontend'

Properties

$enqueued

public mixed $enqueued = false

$tag_inserted

The number of times the loop tag has been inserted.

public int $tag_inserted = 0

Methods

add_active_filters()

Add entry DIV where the active filters list is displayed.

public add_active_filters() : void
Return values
void

add_closing_template_tag()

Add inline comment to wrap the end of the loop.

public add_closing_template_tag(WP_Query $query) : void
Parameters
$query : WP_Query
Return values
void

add_infinite_loading()

Add entry DIV where the pagination is displayed.

public add_infinite_loading() : void

This is used for the infinite loading.

We're using a DIV instead of the default WooCommerce pagination because we need to be able to add the infinite loading after the pagination.

The infinite loading is added via javascript and the intersection observer needs to be able to find the DIV but only once.

Return values
void

add_loading_holder()

Add the loading state holder into the footer.

public add_loading_holder() : void
Return values
void

add_mobile_drawer()

Add entry DIV, where the mobile drawer will be attached to.

public add_mobile_drawer() : void
Return values
void

add_shop_filters()

When a filter group is selected, automatically display it within the shop page.

public add_shop_filters() : void
Return values
void

add_sorting_bar()

Add our custom sorting and results bar.

public add_sorting_bar([mixed $disable_counter = false ]) : void
Parameters
$disable_counter : mixed = false
Return values
void

add_template_tag()

Add inline comment to wrap the loop.

public add_template_tag(WP_Query $query) : void
Parameters
$query : WP_Query
Return values
void

assets()

Load the assets required for the frontend.

public assets() : void
Return values
void

close_hider()

Close the wrapper opened above.

public close_hider() : void
Return values
void

filter_templates()

Filter specific default WC templates only when our frontend scripts are enqueued.

public filter_templates(string $template, string $template_name, array<string|int, mixed> $args, string $template_path, string $default_path) : string
Parameters
$template : string

path to the template.

$template_name : string

Template name.

$args : array<string|int, mixed>

Arguments. (default: array).

$template_path : string

Template path. (default: '').

$default_path : string

Default path. (default: '').

Return values
string

get_backup_pagination()

Get the backup pagination template.

public get_backup_pagination() : string
Return values
string

get_design_settings()

Get the design configuration of the plugin.

public static get_design_settings() : array<string|int, mixed>
Return values
array<string|int, mixed>

get_initial_products_count()

Get the unfiltered initial products count.

public get_initial_products_count() : string
Return values
string

get_language_vars()

Returns a list of language variables that are used in the frontend.

public static get_language_vars() : array<string|int, mixed>

This is used for the translation of the frontend.

Unfortunately, we need this because WP doesn't yet know how to translate lazy loaded components - or at least the documentation lacks any information about it.

Return values
array<string|int, mixed>

get_products_per_page()

Get the number of posts per page.

public get_products_per_page() : string|int

Alternatively fall back to the default number provided by WC.

Return values
string|int

get_search_base_url()

Get the current search base URL.

public static get_search_base_url() : string|false
Return values
string|false

the current search base URL.

get_tag_inserted()

Get the number of times the loop tag has been inserted.

public get_tag_inserted() : int
Return values
int

increase_tag_inserted()

Increase the number of times the loop tag has been inserted.

public increase_tag_inserted() : self
Return values
self

is_product_post_type()

Determine if the query is querying for products.

public is_product_post_type(WP_Query $query) : bool
Parameters
$query : WP_Query
Return values
bool

is_product_taxonomy_page()

Determine if we're on a product taxonomy page.

public is_product_taxonomy_page() : bool
Return values
bool

jsonSerialize()

Use the JsonSerializable interface to add inline json on the frontend.

public jsonSerialize() : array<string|int, mixed>

This data is used globally by all filters throughout the site.

Return values
array<string|int, mixed>

load_translation()

Load translations for assets

public load_translation() : void
Return values
void

open_hider()

Wrap the content into a custom div so that we can hide it via css.

public open_hider() : void
Return values
void

register()

Hook into WP.

public register() : void
Return values
void

shortcode()

Registers the renderer shortcode.

public shortcode(array<string|int, mixed> $atts) : string
Parameters
$atts : array<string|int, mixed>
Return values
string

prepare_json_for_shortcode()

Prepare the filters collection to be used via javascript from the shortcode.

private prepare_json_for_shortcode(Collection $filters) : array<string|int, mixed>
Parameters
$filters : Collection
Return values
array<string|int, mixed>

Search results