WooCommerce Code Reference

WC_Template_Loader
in package

Template loader class.

Table of Contents

$in_content_filter  : bool
Store whether we're processing a product inside the_content filter.
$shop_page_id  : int
Store the shop page ID.
$theme_support  : bool
Is WooCommerce support defined?
comments_template_loader()  : string
Load comments template.
force_single_template_filter()  : string
Force the loading of one of the single templates instead of whatever template was about to be loaded.
in_content_filter()  : bool
Are we filtering content for unsupported themes?
init()  : mixed
Hook in methods.
template_loader()  : string
Load a template.
unsupported_archive_layered_nav_compatibility()  : array
Add layered nav args to WP_Query args generated by the 'products' shortcode.
unsupported_theme_comments_number_filter()  : string
Suppress the comments number on the Shop page for unsupported themes since there is no commenting on the Shop page.
unsupported_theme_init()  : mixed
Hook in methods to enhance the unsupported theme experience on pages.
unsupported_theme_product_content_filter()  : string
Filter the content and insert WooCommerce content on the shop page.
unsupported_theme_remove_review_tab()  : array
Remove the Review tab and just use the regular comment form.
unsupported_theme_shop_content_filter()  : string
Filter the content and insert WooCommerce content on the shop page.
unsupported_theme_single_featured_image_filter()  : string
Prevent the main featured image on product pages because there will be another featured image in the gallery.
unsupported_theme_title_filter()  : string
Filter the title and insert WooCommerce content on the shop page.
get_current_shop_view_args()  : array
Get information about the current shop page view.
get_template_loader_default_file()  : string
Get the default filename for a template.
get_template_loader_files()  : string[]
Get an array of filenames to search for a given template.
unsupported_theme_product_page_init()  : mixed
Hook in methods to enhance the unsupported theme experience on Product pages.
unsupported_theme_shop_page_init()  : mixed
Hook in methods to enhance the unsupported theme experience on the Shop page.
unsupported_theme_tax_archive_init()  : mixed
Enhance the unsupported theme experience on Product Category and Attribute pages by rendering those pages using the single template and shortcode-based content. To do this we make a dummy post and set a shortcode as the post content. This approach is adapted from bbPress.

Properties

Methods

comments_template_loader()

Load comments template.

public static comments_template_loader(string $template) : string
Parameters
$template : string

template to load.

Return values
string

force_single_template_filter()

Force the loading of one of the single templates instead of whatever template was about to be loaded.

public static force_single_template_filter(string $template) : string
Parameters
$template : string

Path to template.

Tags
since
3.3.0
Return values
string

in_content_filter()

Are we filtering content for unsupported themes?

public static in_content_filter() : bool
Tags
since
3.3.2
Return values
bool

template_loader()

Load a template.

public static template_loader(string $template) : string

Handles template usage so that we can use our own templates instead of the theme's.

Templates are in the 'templates' folder. WooCommerce looks for theme overrides in /theme/woocommerce/ by default.

For beginners, it also looks for a woocommerce.php template first. If the user adds this to the theme (containing a woocommerce() inside) this will be used for all WooCommerce templates.

Parameters
$template : string

Template to load.

Return values
string

unsupported_archive_layered_nav_compatibility()

Add layered nav args to WP_Query args generated by the 'products' shortcode.

public static unsupported_archive_layered_nav_compatibility(array $query) : array
Parameters
$query : array

WP_Query args.

Tags
since
3.3.4
Return values
array

unsupported_theme_comments_number_filter()

Suppress the comments number on the Shop page for unsupported themes since there is no commenting on the Shop page.

public static unsupported_theme_comments_number_filter(string $comments_number) : string
Parameters
$comments_number : string

The comments number text.

Tags
since
3.4.5
Return values
string

unsupported_theme_init()

Hook in methods to enhance the unsupported theme experience on pages.

public static unsupported_theme_init() : mixed
Tags
since
3.3.0
Return values
mixed

unsupported_theme_product_content_filter()

Filter the content and insert WooCommerce content on the shop page.

public static unsupported_theme_product_content_filter(string $content) : string

For non-WC themes, this will setup the main shop page to be shortcode based to improve default appearance.

Parameters
$content : string

Existing post content.

Tags
since
3.3.0
Return values
string

unsupported_theme_remove_review_tab()

Remove the Review tab and just use the regular comment form.

public static unsupported_theme_remove_review_tab(array $tabs) : array
Parameters
$tabs : array

Tab info.

Return values
array

unsupported_theme_shop_content_filter()

Filter the content and insert WooCommerce content on the shop page.

public static unsupported_theme_shop_content_filter(string $content) : string

For non-WC themes, this will setup the main shop page to be shortcode based to improve default appearance.

Parameters
$content : string

Existing post content.

Tags
since
3.3.0
Return values
string

Prevent the main featured image on product pages because there will be another featured image in the gallery.

public static unsupported_theme_single_featured_image_filter(string $html) : string
Parameters
$html : string

Img element HTML.

Tags
since
3.3.0
Return values
string

unsupported_theme_title_filter()

Filter the title and insert WooCommerce content on the shop page.

public static unsupported_theme_title_filter(string $title, int $id) : string

For non-WC themes, this will setup the main shop page to be shortcode based to improve default appearance.

Parameters
$title : string

Existing title.

$id : int

ID of the post being filtered.

Tags
since
3.3.0
Return values
string

get_current_shop_view_args()

Get information about the current shop page view.

private static get_current_shop_view_args() : array
Tags
since
3.3.0
Return values
array

get_template_loader_default_file()

Get the default filename for a template.

private static get_template_loader_default_file() : string
Tags
since
3.0.0
Return values
string

get_template_loader_files()

Get an array of filenames to search for a given template.

private static get_template_loader_files(string $default_file) : string[]
Parameters
$default_file : string

The default file name.

Tags
since
3.0.0
Return values
string[]

unsupported_theme_product_page_init()

Hook in methods to enhance the unsupported theme experience on Product pages.

private static unsupported_theme_product_page_init() : mixed
Tags
since
3.3.0
Return values
mixed

unsupported_theme_shop_page_init()

Hook in methods to enhance the unsupported theme experience on the Shop page.

private static unsupported_theme_shop_page_init() : mixed
Tags
since
3.3.0
Return values
mixed

unsupported_theme_tax_archive_init()

Enhance the unsupported theme experience on Product Category and Attribute pages by rendering those pages using the single template and shortcode-based content. To do this we make a dummy post and set a shortcode as the post content. This approach is adapted from bbPress.

private static unsupported_theme_tax_archive_init() : mixed
Tags
since
3.3.0
Return values
mixed