WooCommerce Code Reference

WC_Shortcode_Products
in package

Products shortcode class.

Table of Contents

$attributes  : array<string|int, mixed>
Attributes.
$custom_visibility  : bool
Set custom visibility.
$query_args  : array<string|int, mixed>
Query args.
$type  : string
Shortcode type.
__construct()  : mixed
Initialize shortcode.
get_attributes()  : array<string|int, mixed>
Get shortcode attributes.
get_content()  : string
Get shortcode content.
get_query_args()  : array<string|int, mixed>
Get query args.
get_type()  : string
Get shortcode type.
order_by_rating_post_clauses()  : array<string|int, mixed>
Order by rating.
set_product_as_visible()  : bool
Set product as visible when querying for hidden products.
get_query_results()  : object
Run the query and return an array of data, including queried ids and pagination information.
get_transient_name()  : string
Generate and return the transient name for this shortcode based on the query args.
get_wrapper_classes()  : array<string|int, mixed>
Get wrapper classes.
parse_attributes()  : array<string|int, mixed>
Parse attributes.
parse_legacy_attributes()  : array<string|int, mixed>
Parse legacy attributes.
parse_query_args()  : array<string|int, mixed>
Parse query args.
product_loop()  : string
Loop over found products.
set_attributes_query_args()  : mixed
Set attributes query args.
set_best_selling_products_query_args()  : mixed
Set best selling products query args.
set_categories_query_args()  : mixed
Set categories query args.
set_ids_query_args()  : mixed
Set ids query args.
set_sale_products_query_args()  : mixed
Set sale products query args.
set_skus_query_args()  : mixed
Set skus query args.
set_tags_query_args()  : mixed
Set tags query args.
set_top_rated_products_query_args()  : mixed
Set top rated products query args.
set_visibility_catalog_query_args()  : mixed
Set visibility as catalog.
set_visibility_featured_query_args()  : mixed
Set visibility as featured.
set_visibility_hidden_query_args()  : mixed
Set visibility as hidden.
set_visibility_query_args()  : mixed
Set visibility query args.
set_visibility_search_query_args()  : mixed
Set visibility as search.

Properties

Methods

__construct()

Initialize shortcode.

public __construct([array<string|int, mixed> $attributes = array() ][, string $type = 'products' ]) : mixed
Parameters
$attributes : array<string|int, mixed> = array()

Shortcode attributes.

$type : string = 'products'

Shortcode type.

Tags
since
3.2.0
Return values
mixed

order_by_rating_post_clauses()

Order by rating.

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

Query args.

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

set_product_as_visible()

Set product as visible when querying for hidden products.

public set_product_as_visible(bool $visibility) : bool
Parameters
$visibility : bool

Product visibility.

Tags
since
3.2.0
Return values
bool

get_query_results()

Run the query and return an array of data, including queried ids and pagination information.

protected get_query_results() : object
Tags
since
3.3.0
Return values
objectObject with the following props; ids, per_page, found_posts, max_num_pages, current_page

get_wrapper_classes()

Get wrapper classes.

protected get_wrapper_classes(int $columns) : array<string|int, mixed>
Parameters
$columns : int

Number of columns.

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

parse_attributes()

Parse attributes.

protected parse_attributes(array<string|int, mixed> $attributes) : array<string|int, mixed>
Parameters
$attributes : array<string|int, mixed>

Shortcode attributes.

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

parse_legacy_attributes()

Parse legacy attributes.

protected parse_legacy_attributes(array<string|int, mixed> $attributes) : array<string|int, mixed>
Parameters
$attributes : array<string|int, mixed>

Attributes.

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

set_attributes_query_args()

Set attributes query args.

protected set_attributes_query_args(array<string|int, mixed> &$query_args) : mixed
Parameters
$query_args : array<string|int, mixed>

Query args.

Tags
since
3.2.0
Return values
mixed

set_best_selling_products_query_args()

Set best selling products query args.

protected set_best_selling_products_query_args(array<string|int, mixed> &$query_args) : mixed
Parameters
$query_args : array<string|int, mixed>

Query args.

Tags
since
3.2.0
Return values
mixed

set_categories_query_args()

Set categories query args.

protected set_categories_query_args(array<string|int, mixed> &$query_args) : mixed
Parameters
$query_args : array<string|int, mixed>

Query args.

Tags
since
3.2.0
Return values
mixed

set_ids_query_args()

Set ids query args.

protected set_ids_query_args(array<string|int, mixed> &$query_args) : mixed
Parameters
$query_args : array<string|int, mixed>

Query args.

Tags
since
3.2.0
Return values
mixed

set_sale_products_query_args()

Set sale products query args.

protected set_sale_products_query_args(array<string|int, mixed> &$query_args) : mixed
Parameters
$query_args : array<string|int, mixed>

Query args.

Tags
since
3.2.0
Return values
mixed

set_skus_query_args()

Set skus query args.

protected set_skus_query_args(array<string|int, mixed> &$query_args) : mixed
Parameters
$query_args : array<string|int, mixed>

Query args.

Tags
since
3.2.0
Return values
mixed

set_tags_query_args()

Set tags query args.

protected set_tags_query_args(array<string|int, mixed> &$query_args) : mixed
Parameters
$query_args : array<string|int, mixed>

Query args.

Tags
since
3.3.0
Return values
mixed

set_top_rated_products_query_args()

Set top rated products query args.

protected set_top_rated_products_query_args(array<string|int, mixed> &$query_args) : mixed
Parameters
$query_args : array<string|int, mixed>

Query args.

Tags
since
3.6.5
Return values
mixed

set_visibility_catalog_query_args()

Set visibility as catalog.

protected set_visibility_catalog_query_args(array<string|int, mixed> &$query_args) : mixed
Parameters
$query_args : array<string|int, mixed>

Query args.

Tags
since
3.2.0
Return values
mixed

Set visibility as featured.

protected set_visibility_featured_query_args(array<string|int, mixed> &$query_args) : mixed
Parameters
$query_args : array<string|int, mixed>

Query args.

Tags
since
3.2.0
Return values
mixed

set_visibility_hidden_query_args()

Set visibility as hidden.

protected set_visibility_hidden_query_args(array<string|int, mixed> &$query_args) : mixed
Parameters
$query_args : array<string|int, mixed>

Query args.

Tags
since
3.2.0
Return values
mixed

set_visibility_query_args()

Set visibility query args.

protected set_visibility_query_args(array<string|int, mixed> &$query_args) : mixed
Parameters
$query_args : array<string|int, mixed>

Query args.

Tags
since
3.2.0
Return values
mixed

set_visibility_search_query_args()

Set visibility as search.

protected set_visibility_search_query_args(array<string|int, mixed> &$query_args) : mixed
Parameters
$query_args : array<string|int, mixed>

Query args.

Tags
since
3.2.0
Return values
mixed