WooCommerce has traditionally utilized shortcodes to easily add dynamic content and features to WordPress pages. With the evolution of WordPress towards the Gutenberg block-based editor, focus has shifted from shortcodes to more interactive and visually integrated blocks. While the block editor offers interactively customizable blocks and enhanced editing capabilities; you can still use the legacy shortcodes by adding them inside a shortcode block.
We recognize many shops still lean heavily on shortcode functionality. The following table and linked documentation explain the available WooCommerce shortcodes in detail, with examples of how to use them.
How to use Shortcodes
↑ Back to topWhere to use shortcodes
↑ Back to topShortcodes can be used on pages and posts in WordPress. If you are using the block editor, there is a shortcode block you can use to paste/add the shortcode.
If you are using the classic editor, you can paste the shortcode directly in the page or post content.
Shortcode Attributes
↑ Back to topSeveral shortcodes included in WooCommerce allow you to modify them to make them more specific or display a certain way. You can modify shortcodes by adding attributes (also called arguments/args
) to the shortcode. For example, adding the attribute id
to the [add_to_cart] short code will create an add-to-cart button for a product with a specific product id: [add_to_cart id=”99”] will add the add-to-cart button for the product in your shop with product id 99
.
WooCommerce Shortcodes
↑ Back to topThe following table provides an overview of the available shortcodes included with WooCommerce along with a brief description and a link to the documentation specific to each shortcode and how to use it. Because WooCommerce has shifted toward block-based editing, we’ve also included links to block alternatives for each shortcode in the list where applicable:
Shortcode | Description | Learn more | Block Alternative |
[woocommerce_cart] | Show the cart page. | WooCommerce Page Shortcodes: Cart | Cart block |
[woocommerce_checkout] | Show the checkout page. | WooCommerce Page Shortcodes: Checkout | Checkout Block |
[woocommerce_my_account] | Show the user account page. | WooCommerce Page Shortcodes: My Account | None yet |
[woocommerce_order_tracking] | Show the order tracking form. Has attributes. | WooCommerce Page Shortcodes: Order Tracking Form | None |
[product_page] | Displays a full single product page by ID or SKU | WooCommerce Page Shortcodes: Product Page | Custom product page templates can be made via store editing |
[products] | Display products by specific parameters. Has attributes. | Products Shortcodes | Products Collection Block (and others*) |
[product_category] | Display products in a specified category. Has attributes. | Product Category Shortcodes | Product Collection Block |
[product_categories] | Display product categories. Has attributes. | Product Category Shortcodes | None yet |
[add_to_cart] | Show “add to cart” button for a product. Has attributes. | Related Products, Add-to-Cart, and Notification Shortcodes: Add-to-Cart | Available on Single Product Page Templates |
[add_to_cart_url] | Get URL of “add to cart” for a product. Has attributes. | Related Products, Add-to-Cart, and Notification Shortcodes: Add-to-Cart URL | None |
[shop_messages] | Show WooCommerce messages. Use when wanting to show shop messages on non-WooCommerce posts or pages. | Related Products, Add-to-Cart, and Notification Shortcodes: Shop Messages | Store Notices Block |
* There are a variety of blocks to display products with different options such as 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 troubleshooting shortcodes, take a look at Troubleshooting Shortcodes and Code Snippets documentation for assistance with common problems related to shortcodes.
Questions and support
↑ Back to topDo 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.