WooCommerce Shortcodes Usage Guide

Woo WordPress plugin comes with shortcodes to insert content in posts & pages, check a list of the WooCommerce shortcodes & their usage guide

By Claudio Pires
Updated on October 4, 2022
WooCommerce Shortcodes Usage Guide

WooCommerce WordPress plugin comes with several shortcodes that can be used to insert content inside posts and pages. See here a list of the WooCommerce shortcodes and the usage guide.

WooCommerce is a widely used free e-commerce/store plugin for WordPress. It comes with various shortcodes that can be used to customize your online store, such as the interface, checkout functionality, product listing etc. In this article, I made a complete list of all the WooCommerce shortcodes, and their usage so new/advanced users can benefit from WooCommerce.

WooCommerce Shortcodes for Pages

WooCommerce Shortcodes Usage Guide
WooCommerce Shortcodes Usage Guide

When you first install WordPress, it automatically creates 4 pages required to run your store – Shop, Cart, Checkout, and My Account. These pages have shortcodes that WooCommerce includes from its core. So if WooCommerce couldn’t create a page for some reason or you accidentally deleted it, you can recreate it with the proper shortcode and specify in the settings.

woocommerce_cart – Firstly, shows the cart page
woocommerce_checkout – Secondly, display the checkout page
woocommerce_my_account – shows the user account page
woocommerce_order_tracking – Finally, shows the order tracking form

Shop WooCommerce shortcodes

Shop page is your store page. It showcases all of your WooCommerce products and presents them to your visitors. Currently, there is no shortcode to customize the content of this page. WooCommerce can automatically detect when the shop page is loading and list your products accordingly.

Please add the ‘[‘ and ‘]’ characters on before and after the WooCommerce shortcodes to make it work.

Cart

WooCommerce creates a Cart page for its shopping cart functionality. This is the cart shortcode:

[woocommerce_cart]

The cart shortcode does not accept any additional parameter/argument. It shows the content of the shopping cart such as item details, coupon codes, shipping, taxes etc.

Checkout WooCommerce shortcodes usage guide

Check out page provides the checkout functionality for your customers. This is the WooCommerce shortcode for the checkout page:

woocommerce_checkout

The checkout shortcode does not accept any additional parameter/argument. It shows all the information collected from a user during checkout such as billing info, shipping info, payment method etc.

My Account WooCommerce shortcodes

My Account page shows a dashboard to the logged-in customers. This is the WooCommerce shortcode for the My Account page:

woocommerce_my_account

Customer can view their past orders, and downloads, and update their personal details such as billing info, shipping info, and account password from the My Account page.

Order Tracking Form

Order Tracking Form page is not created automatically by default. This is an optional page that you can manually create to let a customer check the status of an order. This is the WooCommerce shortcode for the Order Tracking Form page:

woocommerce_order_tracking

To see the status of an order, the customer needs to enter their order details in the Order Tracking Form.

More WooCommerce Shortcodes

WooCommerce Shortcodes Usage Guide
WooCommerce Shortcodes Usage Guide

Some WooCommerce shortcodes can be used anywhere you want.

Recent Products

You can use this WooCommerce shortcode to list a set of recent products.

recent_products per_page="12" columns="4"

You determine how many products to show on the page with the “per_page” attribute. The “columns” attribute can be used to control how many columns wide the products should be before wrapping.

Featured Products

You can use this WooCommerce shortcode to display products that have been set as “featured” in WooCommerce.

featured_products per_page="12" columns="4"

Product WooCommerce shortcodes usage guide

This WooCommerce shortcode allows you to show a single product by ID or SKU.

[product id="99"
[product sku="FOO"

In order to find the ID of a product, you can hover over that particular product in the WooCommerce Products menu.

Products

This WooCommerce shortcode allows you to show multiple products by ID or SKU.

products ids="1, 2, 3, 4, 5"
products skus="foo, bar, baz"

Add to Cart

This WooCommerce shortcode shows the price and adds to cart button of a single product by ID.

add_to_cart id="99"

Add to Cart URL WooCommerce shortcodes usage guide

This WooCommerce shortcode prints the URL on the add-to-cart button of a single product by ID.

[add_to_cart_url id="99"]

Product Category

This WooCommerce shortcode shows multiple products of a category by the slug.

product_category category="appliances"

You can find the slug of a particular category under WooCommerce > Products > Categories.

Product Categories

This WooCommerce shortcode can display multiple product categories in a loop.

product_categories number="12" ids="2, 6, 7, 10"

You can use the number parameter to display the number of products and the ids field (containing a comma-separated list of category IDs) to choose which categories to show.

There is also the parent parameter that you can set to 0 to only display the top level categories.

product_categories number="12" parent="0"

In order to find the ID of a category, go to the Product Categories screen and hover over the category. The ID appears in the URL.

Product Page

This WooCommerce shortcode shows the full product page of a WooCommerce product by ID or SKU.

product_page id="99"
product_page sku="FOO"

Sale Products

This WooCommerce shortcode showcases all of your products that are on sale.

sale_products per_page="12" columns="4"

Best-Selling Products

This WooCommerce shortcode showcases all of your best-selling products.

[best_selling_products per_page="12" columns="4"]

Related Products

This WooCommerce shortcode lists all of your related products.

[related_products per_page="12" columns="4"]

Top-Rated Products

This WooCommerce shortcode showcases all of your top-rated products.

[top_rated_products per_page="12" columns="4"]

Product Attribute

This WooCommerce shortcode lists products by attributes.

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

Product Sorting

You can use the “orderby” or “order” parameter to sort shortcodes that display multiple products or products of a category. The “orderby” parameter can accept one of these values:

  • menu_order
  • title
  • date
  • rand
  • id

The “order” parameter can accept one of these values:

  • asc
  • desc

For example, This shortcode will sort 3 products (with SKUs foo, bar and baz) by date in descending order:

[products skus="foo, bar, baz" orderby="date" order="desc"]

Disclosure: I receive compensation from the companies whose products I review. However, I recommend products that I use, and the opinions expressed here are my own.

WooCommerce Shortcodes Usage Tutorial and Guide With Examples

Example 1 – Randomized Sale Items

This shortcode explicity states four products with four columns (which will be one row), showing the most popular on-sale items

I want to display four random on-sale products.

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

This shortcode explicitly states four products with four columns (which will be one row), showing the most popular on-sale items. It also adds a CSS class quick-sale, which I can modify in my theme.

Example 2 – Featured Products

WooCommerce Shortcodes Usage guide I would like to display two featured products per row

I would like to display two featured products per row, with a maximum of four items. This shortcode states that up to four effects can be loaded in two columns and must be marked. Although not explicitly stated, it uses default settings such as sorting by title (A to Z).

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

Example 3 – Best Sellers of Your WooCommerce Shop Shortcode Usage Guide

WooCommerce shortcode usage guide tutorial I want to display my three top best selling products in one row.

I want to showcase my three best-selling products in a row.

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

Example 4 – Latest Products

I want to show the newest products first 4 columns

I want to show the newest products first – four in a row. For this, we use the post ID (generated when the product page is created) and the order and order by commands. Since you can’t see the post ID from the front end, the ID#s are overlaid on top of the image. As a result this will be the WooCommerce WordPress plugin shortcodes examples:

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

Example 5 – Specific Categories

I just want to show hoodies and shirts, but no accessories

I just want to show hoodies and shirts, but no accessories. I use two rows of four.

[products limit="8" columns="4" category="hoodies, tshirts" cat_operator="AND"]

In alt options is, we just want to display products, not in those categories. All I need to change is the cat_operator to NOT IN.

[products limit="8" columns="4" category="hoodies, tshirts" cat_operator="NOT IN"]

Example 6 – Attribute Display WooCommerce WordPress Plugin Shortcodes

Attribute Display woocommerce shortcode usage guide

Each piece of clothing has an attribute, “spring/summer” or “autumn/winter” depending on the season, and some accessories can be worn year-round. In this example, I want the “Spring/Summer” item to appear on each row of three products.

This attribute snail is seasonal, and the attribute has a cold and warm. I also want them sorted from newest to oldest. Or, if I only want to show cold-weather products, I can add NOT IN as my term_operator: note that by using NOT IN, I’m excluding products in “spring/summer” and “autumn/winter”. “Health) condition. If I wanted to show all cold weather gear, including these standard accessories, I would change the term from warm to cold. Hope it helps you on using the WooCommerce WordPress plugin shortcodes.

[products columns="3" attribute="season" terms="warm" orderby="date"]
[products columns="3" attribute="season" terms="warm" terms_operator="NOT IN"]
Claudio Pires

Claudio Pires is the co-founder of Visualmodo, a renowned company in web development and design. With over 15 years of experience, Claudio has honed his skills in content creation, web development support, and senior web designer. A trilingual expert fluent in English, Portuguese, and Spanish, he brings a global perspective to his work. Beyond his professional endeavors, Claudio is an active YouTuber, sharing his insights and expertise with a broader audience. Based in Brazil, Claudio continues to push the boundaries of web design and digital content, making him a pivotal figure in the industry.