You are currently viewing Shortcodes included with WooCommerce

Shortcodes included with WooCommerce

WooCommerce comes with several shortcodes that can be used to insert content inside posts and pages to display products and filters as per your requirements.

Page Shortcodes

Woocommerce page shortcodes display woocommerce pages in your wordpress website like cart, checkout and account. When we install woocommerce then below shortcodes automatically added to their respective pages and don’t need to create manually.

[woocommerce_cart] – display the cart page
[woocommerce_checkout] – display the checkout page
[woocommerce_my_account] – display the user account page
[woocommerce_order_tracking] – display the order tracking form


Used on the cart page, the cart shortcode displays cart content and interface for coupon codes and other cart bits and pieces.

Args: none



Used on the checkout page, the checkout shortcode displays the checkout process.

Args: none


My Account

Shows the ‘my account’ section where the customer can view past orders and update their information. You can specify the number of orders to show. By default, it’s set to 15 (use -1 to display all orders.)


     'current_user' => ''
Current user argument is automatically set using get_user_by( ‘id’, get_current_user_id() ).

Order Tracking Form

Lets a user see the status of an order by entering their order details.

Args: none



The products shortcode is one of our most robust shortcodes, which can replace various other strings used in earlier versions of WooCommerce.

The [products] shortcode allows you to display products by post ID, SKU, categories, attributes, with support for pagination, random sorting, and product tags, replacing the need for multiples shortcodes such as: [featured_products], [sale_products], [best_selling_products], [recent_products], [product_attribute], and [top_rated_products].

Display Product Attributes

limit – The number of products to display. Defaults to and -1 (display all) when listing products, and -1 (display all) for categories.
columns – The number of columns to display. Defaults to 4.
paginate – Toggles pagination on. Use in conjunction with limit. Defaults to false set to true to paginate .
orderby – Sorts the products displayed by the entered option. One or more options can be passed by adding both slugs with a space between them. Available options are:
date – The date the product was published.
id – The post ID of the product.
menu_order – The Menu Order, if set (lower numbers display first).
popularity – The number of purchases.
rand – Randomly order the products on page load (may not work with sites that use caching, as it could save a specific order).
rating – The average product rating.
title – The product title. This is the default orderby mode.
skus – Comma-separated list of product SKUs.
category – Comma-separated list of category slugs.
tag – Comma-separated list of tag slugs.
order – States whether the product order is ascending (ASC) or descending (DESC), using the method set in orderby. Defaults to ASC.
class – Adds an HTML wrapper class so you can modify the specific output with custom CSS.
on_sale – Retrieve on sale products. Not to be used in conjunction with best_sellingor top_rated.
best_selling – Retrieve the best selling products. Not to be used in conjunction with on_sale or top_rated.
top_rated – Retrieve top rated products. Not to be used in conjunction with on_saleor best_selling.

Woocommerce product shortcode example

Random Sale Products

[products limit="4" columns="4" orderby="popularity" class="quick-sale" on_sale="true" ]

Featured Products

[products limit="4" columns="2" visibility="featured" ]

Best Selling Products

[products limit="3" columns="3" best_selling="true" ]

Newest Products

[products limit="4" columns="4" orderby="id" order="DESC" visibility="visible"]

Specific Category Products

[products limit="8" columns="4" category="rings, earings" cat_operator="AND"]

[products limit="8" columns="4" category="bracelts, gemstone" cat_operator="NOT IN"]

Product Attribute Display

[products columns="3" attribute="color" terms="red" orderby="date"]

[products columns="3" attribute="color" terms="blue" terms_operator="NOT IN"]

Show Top Level Product Categories Only

[product_categories number="0" parent="0"]

Show Only Products With tag “jewellery”

[products tag="jewellery"]

Product Page

Display single product page by ID or SKU.

[product_page id="35"]
[product_page sku="SK001"]

Related Products

//List all related product
     'limit' => '8',
     'columns' => '4',
     'orderby' => 'title'

[related_products limit="8"]

Add to Cart

Display the price and add to cart button of a single product by ID.

      'id' => '220',
      'style' => 'border:4px solid #ccc; padding: 12px;',
      'sku' => 'SK78'
      'show_price' => 'TRUE'
      'class' => 'CSS-CLASS'
      'quantity' => '1';

[add_to_cart id="99"]

Add to Cart URL

Echo the URL on the add to cart button of a single product by ID.
      'id' => '99',
      'sku' => 'FOO'

[add_to_cart_url id="99"]

Display WooCommerce notifications on non-WooCommerce pages

[shop_messages] allows you to show WooCommerce notifications (like, ‘The product has been added to cart’) on non-WooCommerce pages like custom pages.

Leave a Reply