WooCommerce Code Reference

WC_Shortcodes
in package

WooCommerce Shortcodes class.

Table of Contents

best_selling_products()  : string
List best selling products on sale.
cart()  : string
Cart page shortcode.
checkout()  : string
Checkout page shortcode.
featured_products()  : string
Output featured products.
init()  : mixed
Init shortcodes.
my_account()  : string
My account page shortcode.
order_by_rating_post_clauses()  : array<string|int, mixed>
Order by rating.
order_tracking()  : string
Order tracking page shortcode.
product()  : string
Display a single product.
product_add_to_cart()  : string
Display a single product price + cart button.
product_add_to_cart_url()  : string
Get the add to cart URL for a product.
product_attribute()  : string
List products with an attribute shortcode.
product_categories()  : string
List all (or limited) product categories.
product_category()  : string
List products in a category shortcode.
product_page()  : string
Show a single product page.
products()  : string
List multiple products shortcode.
recent_products()  : string
Recent Products shortcode.
related_products()  : string
List related products.
sale_products()  : string
List all products on sale.
shop_messages()  : string
Show messages.
shortcode_wrapper()  : string
Shortcode Wrapper.
top_rated_products()  : string
List top rated products on sale.

Methods

best_selling_products()

List best selling products on sale.

public static best_selling_products(array<string|int, mixed> $atts) : string
Parameters
$atts : array<string|int, mixed>

Attributes.

Return values
string

checkout()

Checkout page shortcode.

public static checkout(array<string|int, mixed> $atts) : string
Parameters
$atts : array<string|int, mixed>

Attributes.

Return values
string

Output featured products.

public static featured_products(array<string|int, mixed> $atts) : string
Parameters
$atts : array<string|int, mixed>

Attributes.

Return values
string

my_account()

My account page shortcode.

public static my_account(array<string|int, mixed> $atts) : string
Parameters
$atts : array<string|int, mixed>

Attributes.

Return values
string

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
deprecated
3.2.0

Use WC_Shortcode_Products::order_by_rating_post_clauses().

Return values
array<string|int, mixed>

order_tracking()

Order tracking page shortcode.

public static order_tracking(array<string|int, mixed> $atts) : string
Parameters
$atts : array<string|int, mixed>

Attributes.

Return values
string

product()

Display a single product.

public static product(array<string|int, mixed> $atts) : string
Parameters
$atts : array<string|int, mixed>

Attributes.

Return values
string

product_add_to_cart()

Display a single product price + cart button.

public static product_add_to_cart(array<string|int, mixed> $atts) : string
Parameters
$atts : array<string|int, mixed>

Attributes.

Return values
string

product_add_to_cart_url()

Get the add to cart URL for a product.

public static product_add_to_cart_url(array<string|int, mixed> $atts) : string
Parameters
$atts : array<string|int, mixed>

Attributes.

Return values
string

product_attribute()

List products with an attribute shortcode.

public static product_attribute(array<string|int, mixed> $atts) : string

Example [product_attribute attribute="color" filter="black"].

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

Attributes.

Return values
string

product_categories()

List all (or limited) product categories.

public static product_categories(array<string|int, mixed> $atts) : string
Parameters
$atts : array<string|int, mixed>

Attributes.

Return values
string

product_category()

List products in a category shortcode.

public static product_category(array<string|int, mixed> $atts) : string
Parameters
$atts : array<string|int, mixed>

Attributes.

Return values
string

product_page()

Show a single product page.

public static product_page(array<string|int, mixed> $atts) : string
Parameters
$atts : array<string|int, mixed>

Attributes.

Return values
string

products()

List multiple products shortcode.

public static products(array<string|int, mixed> $atts) : string
Parameters
$atts : array<string|int, mixed>

Attributes.

Return values
string

recent_products()

Recent Products shortcode.

public static recent_products(array<string|int, mixed> $atts) : string
Parameters
$atts : array<string|int, mixed>

Attributes.

Return values
string

List related products.

public static related_products(array<string|int, mixed> $atts) : string
Parameters
$atts : array<string|int, mixed>

Attributes.

Return values
string

sale_products()

List all products on sale.

public static sale_products(array<string|int, mixed> $atts) : string
Parameters
$atts : array<string|int, mixed>

Attributes.

Return values
string

shortcode_wrapper()

Shortcode Wrapper.

public static shortcode_wrapper(array<string|int, string> $function[, array<string|int, mixed> $atts = array() ][, array<string|int, mixed> $wrapper = array('class' => 'woocommerce', 'before' => null, 'after' => null) ]) : string
Parameters
$function : array<string|int, string>

Callback function.

$atts : array<string|int, mixed> = array()

Attributes. Default to empty array.

$wrapper : array<string|int, mixed> = array('class' => 'woocommerce', 'before' => null, 'after' => null)

Customer wrapper data.

Return values
string

top_rated_products()

List top rated products on sale.

public static top_rated_products(array<string|int, mixed> $atts) : string
Parameters
$atts : array<string|int, mixed>

Attributes.

Return values
string