WooCommerce Shortcodes

WooCommerce Shortcodes Guide

A few years ago, it took a significant amount of investment to create any type of retail business. You had to buy the best property in order to open a store–and that was just the beginning. However, things have changed for the better.

Nowadays, you can start a successful retail business without spending a lot of money. With the right domain and user-friendly website, you can earn a pretty penny in no time.

While many consider Shopify to be their choice platform for creating eCommerce websites, most businesses love the robust experience of creating a web store on WooCommerce. This is why 26% of the top 1 million sites prefer WooCommerce over anything.

One of the most compelling features of this eCommerce CMS is WooCommerce Shortcodes. With the help of the shortcodes, you can create customer-centric and scalable online stores without a lot of hassle.

What are WooCommerce Shortcodes?

What are WooCommerce Shortcodes?

Shortcodes can be defined as function-specific shortcuts that can provide essential features by triggering functions present within the code. Since WooCommerce is all about creating amazing online shops, you can use WooCommerce Shortcodes to design conversion-focused and shopper-friendly experiences.

For example, with the help of shortcodes, you can set featured products, create quick sale conditions, create custom display rules, and much more.

Shortcodes can be used anywhere in your store. You can use them to customize your store, show off your products, and even add call-to-action buttons. Shortcodes are excellent for beginners because you don’t require any prior coding knowledge or experience to use these shortcodes. If you have customization ideas for your online store, you can achieve them quickly with WooCommerce shortcodes. 

In summary, WooCommerce shortcodes are excellent for:

  • Saving you a significant amount of time because you do not have to customize codes. You can use these shortcodes quickly and more efficiently to get the job done. 
  • These shortcodes are highly flexible. You can also use the same shortcode for multiple situations depending on your set parameters. 
  • WooCommerce shortcodes don’t add a markup to post content, so you can easily edit the style of the page later.

How are WooCommerce Shortcodes beneficial for beginners?

If you are a beginner, the WooCommerce shortcodes grant complete control of your site. These shortcodes allow you to display products and add call-to-action buttons or other feature buttons anywhere on your store without having any web development knowledge or experience. WooCommerce shortcodes significantly simplify the process of coding to the point that you do not require any professional assistance.

WooCommerce shortcodes are excellent for new businesses who wish to experiment with new strategies and expect easy and detailed customization. These shortcodes allow you to add products to the homepage, display products anywhere on the website, and also create grips for top-selling/on-sale items.

Beginners can even easily add an order tracking page to their website to add more value to the customer experience. In conclusion, WooCommerce shortcodes open a treasure box of easy customization options for beginners.

Reasons to utilize WooCommerce shortcodes

Shortcodes are a powerful method to personalize your WooCommerce online store.

You can add specialized features or content to the e-commerce site plus particular pages of your content by copying a WooCommerce shortcode based on various factors that can be updated (in the code).

You can, for example, use WooCommerce product shortcodes to control which goods appear in your store as well as the way they are ordered.

You may also utilize WooCommerce shortcodes to place “Add to Cart” buttons in key places on your website, such as at the end of a blog post.

These kinds of features might help set your store apart from the competition. This will enhance the user experience and also encourage more visitors to shop at your e-commerce site. 

How to use shortcodes

You can use shortcodes in the following two ways:

  1. By manual input
  2. By plugin

In this guide, you will learn how to use WooCommerce shortcodes manually properly. This method gives you more flexibility and works great, even if you are a beginner. You will also learn how to use the plugin as well.

Where to use WooCommerce Shortcodes

Since shortcodes are part of the WooCommerce code, you can use these on a page or post.

One of the best ways to use a shortcode is through the block editor. In order to put a shortcode, create a new content block, and search for Shortcode. You will find the option to create one under the Widgets section.

WooCommerce Shortcodes 1

Once created, just type (or copy-paste) the WooCommerce shortcode in the required field.

If you are utilizing the classic editor, then just place the shortcode in the Visual area of a page or post.

Page Shortcodes

In this section, we will share the essential shortcodes for a WooCommerce store. Without these shortcodes, WooCommerce cannot perform as expected. The following shortcodes need to be included somewhere on your website:

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

Generally, the onboarding wizard from WooCommerce automatically generates these shortcodes on pages. Therefore, there might not be a need to use these manually except for [woocommerce_order_tracking] as it is considered optional, depending on your business model.

Args (aka Arguments)

In order to provide more flexibility, some shortcodes can be controlled through short syntaxes known as “args” (or arguments). Args amplifies the power of shortcodes and provides you with options that you can use to make better shopping experiences.

When it comes to Page Shortcodes, only [woocommerce_my_account] has an arg:

 array(
     'current_user' => ''
 )

Through this arg, you can set the number of current and previous orders to show. The default is 15; however, you can set any number of your liking or -1 to display all orders.

Products Shortcode

The [products] shortcode is amongst the most commonly used and trusted shortcodes by WooCommerce. The reason behind the popularity of this WooCommerce shortcode is that it has replaced several other strings that were previously used in earlier versions of WooCommerce.

The specialty of the [products] shortcode is that you can use this shortcode to display products according to their ID, SKUs, categories, and attributes with support for pagination, product tags, and random sorting.

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

The [products] shortcode replaces the need for additional WooCommerce (version 3.2. or below) shortcodes including 

[featured_products], [best_selling_products][sale_products], [product_attribute], [top_rated_products], and [recent_products].  

Note: With WooCommerce Core version 3.6, you now have access to a range of product blocks. So, how are product blocks different from shortcodes? They are more straightforward and convenient to configure as compared to shortcodes.

Other Available Products Shortcodes

Product: The [products] shortcode is used for displaying multiple products. On the contrary, the [product] shortcode is used for displaying a single product according to ID or SKU.

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

You can hover over the WooCommerce products menu to find the ID of a product.

Product Category by Slug: The WooCommerce [product_category] is used to display multiple products of a category by the slug.

[product_category category="appliances"] 

Product Categories: The WooCommerce[product_categories] shortcode allows you to display several product categories in a single loop. 

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

You can customize by number parameters to display a specific number of products, and the ids field to choose the categories that you wish to display.

You can also utilize the parent parameter and set it to zero to display only the top-level categories.

product_categories number="12" parent="0" 

Note: Hover over the category to find the ID of a category that appears in the URL.

Product Attribute: The WooCommerce [product_attribute] shortcode allows you to list the products by their attributes.

product_attribute attribute="color" filter="black"

Product Sorting: If you want to sort multiple products or multiple products of a category, you can use the “orderby” or “order” parameter. 

The “orderby” parameter allows the following values:

  • date
  • title
  • rand
  • id
  • menu_order

The “order” parameter allows the following values:

  • asc
  • desc
products skus="foo, bar, baz" orderby="date" order="desc" 

Recent Products: The WooCommerce [recent_products] shortcode allows you to list the recently added products.

recent_products per_page="12" columns="4" 
Recent Product

You can control the number of products that you want to display per page with the “per_page” attribute. And determine the number of columns with the “columns” attribute.

Featured Products: The WooCommerce [featured_products] allows you to display the “featured” products. It can be used to boost the sale of specific products.

featured_products per_page="12" columns="4" 
Featured Product

Sale Products: You can use this WooCommerce shortcode to display your selection of products that are on sale or discounted price.

sale_products per_page="12" columns="4
Sale Product

Best-Selling Products: You can use this WooCommerce shortcode to bring your best-selling items to the forefront. 

best_selling_products per_page="12" columns="4"
Best Selling Product

Related Products: You can use this WooCommerce shortcode if you wish to display all of your related products.

related_products per_page="12" columns="4" 

Top-Rated Products: You can use this WooCommerce shortcode to display your range of top-rated products.

top_rated_products per_page="12" columns="4" 

Add to Cart URL: You can use this WooCommerce shortcode to print the URL on the ‘add to cart’ button on each product by ID.

add_to_cart_url id="99"

Product Page: You can use this WooCommerce shortcode to showcase the full product page of a WooCommerce product by ID or SKU.

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

When to use a plugin for WooCommerce shortcodes?

As you can see, WooCommerce shortcodes are quite easy to use; however, they can get overwhelming for novice users. Currently, there is no default button or menu for this feature. However, you can get one if you want by using plugins:

  • WooCommerce Shortcodes by WooThemes and Claudio Sanches
  • Woo Shortcodes Kit By Alberto G.

WooCommerce Shortcodes plugin is not an official plugin by the core development team. Created by WooThemes and Claudio Sanches, the plugin provides a dropdown menu for all the available WooCommerce shortcodes. It comes handy when you are building the store on the classic (TinyMCE) visual editor.

Woo Shortcodes Kit provides a different take on shortcode usage. Developed by Alberto G., this plugin is something every developer and store owner should use. With built-in templates and toggle controls, this WooCommerce shortcodes plugin removes the guesswork of using shortcodes.

Both of these plugins are excellent at what they do. However, these should be tested on a staging site to check their functionalities.

Troubleshooting WooCommerce Shortcodes

Sometimes, the shortcodes may not provide the desired results. There are a few common errors made by developers while using shortcodes. One of the biggest mistakes is to put the shortcode between < pre > tags. This can be easily fixed. Simply click on the Text tab of the classic editor and remove < pre > and < /pre > tags.

Troubleshooting WooCommerce Shortcodes

The accidental use of curly quote marks (“) is also a common problem. This one is tough to spot. Therefore, always make sure you are using straight quote marks (“) while using WooCommerce shortcodes.

Read Also

Sarah is a writer by profession and passion. She is a real tech-savvy who loves everything tech! Talk about the latest tech releases, latest news from the tech world, on-trend tech gadgets, or simple tech hacks – Sarah knows it all! Being a movie enthusiast, she always has a close eye on the latest releases. Her insights about how well the movie will do on the box offices are surprisingly always correct! We call her the “Encyclopaedia of Movies”.