WooCommerce Code Reference

Search results

WC_Shortcodes

WooCommerce Shortcodes class.

Table of Contents

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

Methods

shortcode_wrapper()

Shortcode Wrapper.

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

Callback function.

$atts : array = array()

Attributes. Default to empty array.

$wrapper : array = array('class' => 'woocommerce', 'before' => null, 'after' => null)

Customer wrapper data.

Return values
string

checkout()

Checkout page shortcode.

public static checkout( $atts : array ) : string
Parameters
$atts : array

Attributes.

Return values
string

order_tracking()

Order tracking page shortcode.

public static order_tracking( $atts : array ) : string
Parameters
$atts : array

Attributes.

Return values
string

my_account()

My account page shortcode.

public static my_account( $atts : array ) : string
Parameters
$atts : array

Attributes.

Return values
string

product_category()

List products in a category shortcode.

public static product_category( $atts : array ) : string
Parameters
$atts : array

Attributes.

Return values
string

product_categories()

List all (or limited) product categories.

public static product_categories( $atts : array ) : string
Parameters
$atts : array

Attributes.

Return values
string

recent_products()

Recent Products shortcode.

public static recent_products( $atts : array ) : string
Parameters
$atts : array

Attributes.

Return values
string

products()

List multiple products shortcode.

public static products( $atts : array ) : string
Parameters
$atts : array

Attributes.

Return values
string

product()

Display a single product.

public static product( $atts : array ) : string
Parameters
$atts : array

Attributes.

Return values
string

product_add_to_cart()

Display a single product price + cart button.

public static product_add_to_cart( $atts : array ) : string
Parameters
$atts : array

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( $atts : array ) : string
Parameters
$atts : array

Attributes.

Return values
string

sale_products()

List all products on sale.

public static sale_products( $atts : array ) : string
Parameters
$atts : array

Attributes.

Return values
string

best_selling_products()

List best selling products on sale.

public static best_selling_products( $atts : array ) : string
Parameters
$atts : array

Attributes.

Return values
string

top_rated_products()

List top rated products on sale.

public static top_rated_products( $atts : array ) : string
Parameters
$atts : array

Attributes.

Return values
string

featured_products()

Output featured products.

public static featured_products( $atts : array ) : string
Parameters
$atts : array

Attributes.

Return values
string

product_page()

Show a single product page.

public static product_page( $atts : array ) : string
Parameters
$atts : array

Attributes.

Return values
string

shop_messages()

Show messages.

public static shop_messages( ) : string
Return values
string

order_by_rating_post_clauses()

Order by rating.

public static order_by_rating_post_clauses( $args : array ) : array
Parameters
$args : array

Query args.

Tags
deprecated

Use WC_Shortcode_Products::order_by_rating_post_clauses().

Return values
array

product_attribute()

List products with an attribute shortcode.

public static product_attribute( $atts : array ) : string

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

Parameters
$atts : array

Attributes.

Return values
string

related_products()

List related products.

public static related_products( $atts : array ) : string
Parameters
$atts : array

Attributes.

Return values
string
Back to the top