Shortcodes included with WooCommerce

WooCommerce has traditionally utilized shortcodes to add dynamic content and features to WordPress pages. With WordPress’s evolution toward the Gutenberg block-based editor, the focus has shifted from shortcodes to more interactive and visually integrated blocks.

While the block editor offers interactively customizable blocks and enhanced editing capabilities, we recognize many stores still lean heavily on shortcodes. You can use legacy shortcodes inside a shortcode block.

Note: WooCommerce blocks are the simplest, most flexible way to display products on posts and pages. Learn more about WooCommerce blocks.

Help shape the future of WooCommerce! Our team is always working to build tools that will help your business to succeed, and feedback plays a vital role in that process.

To help make sure our products are the best they can be, we regularly conduct customer research studies — and we’d love you to add your voice to the conversation. Learn more about customer research studies.

How to use shortcodes

↑ Back to top

Where to use shortcodes

↑ Back to top

Shortcodes can be used on WordPress posts and pages. If you are using the block editor, you can paste the shortcode into a shortcode block.

The shortcode block with a shortcode pasted inside it.
You can insert a shortcode in the block editor via the shortcode block.

If you are using the Classic Editor, you can paste the shortcode directly into the page or post content. 

Shortcode attributes

↑ Back to top

Some shortcodes allow you to modify them to make them more specific or display content in a certain way. You can modify shortcodes by adding attributes (AKA arguments or args) to them.

For example, adding the attribute id to the [add_to_cart] shortcode will create an add-to-cart button for a specific product. [add_to_cart id=”99”] displays an add-to-cart button for the product with an ID of 99 in your shop.

WooCommerce shortcodes

↑ Back to top

The table below provides an overview of the shortcodes available in WooCommerce. Each item includes a brief description and a link to shortcode-specific documentation.

As WooCommerce has moved to block-based store editing, we’ve also included links to block alternatives for each shortcode (where applicable).

ShortcodeDescriptionLearn moreBlock alternative
[woocommerce_cart]Displays the cart page.Cart shortcodeCart block
[woocommerce_checkout]Displays the checkout page.Checkout shortcodeCheckout block
[woocommerce_my_account]Displays the user account page.My account shortcodeNone yet
[woocommerce_order_tracking]Displays the order tracking form; has attributes.Order tracking shortcodeNone
[product_page]Displays a full single product page by ID or SKU.Product page shortcodeCustom product page templates can be made using the store editor
[products]Displays products by specific parameters; has attributes.Product shortcodesProduct collection block (and others*)
[product_category]Displays products in a specified category; has attributes.Product category shortcodesProduct collection block
[product_categories]Displays product categories; has attributes.Product category shortcodesNone yet
[add_to_cart]Displays an add-to-cart button for a product; has attributes.Add-to-cart shortcodeAvailable on single product page templates
[add_to_cart_url]Gets the URL of an add-to-cart button for a product; has attributes.Add-to-cart URL shortcodeNone
[shop_messages]Displays shop messages on non-WooCommerce posts or pages.Shop message shortcodeStore notices block

Note: A variety of blocks display products with different options, including the all products block, hand-picked products block, products by category block, products by tag block, and more.

These are being deprecated in favor of the more robust and versatile product collection block.

If you need help, please review troubleshooting shortcodes and code snippets for assistance with common shortcode-related problems. 

Questions and support

↑ Back to top

Do you still have questions and need assistance? 

This documentation is about the free, core WooCommerce plugin, for which support is provided in our community forums on WordPress.org. By searching this forum, you’ll often find that your question has been asked and answered before.

If you haven’t created a WordPress.org account to use the forums, here’s how.

  • If you’re looking to extend the core functionality shown here, we recommend reviewing available extensions in the WooCommerce Marketplace.
  • Need ongoing advanced support or a customization built for WooCommerce? Hire a Woo Agency Partner.
  • Are you a developer building your own WooCommerce integration or extension? Check our Developer Resources.

If you weren’t able to find the information you need, please use the feedback thumbs below to let us know.

Use of your personal data
We and our partners process your personal data (such as browsing data, IP Addresses, cookie information, and other unique identifiers) based on your consent and/or our legitimate interest to optimize our website, marketing activities, and your user experience.