Woocommerce brings with it hundreds of shortcodes when installed, which we can take advantage of to apply certain functions without the need for plugins or a visual layout anywhere in our online store.
A shortcode is a function contained in a small piece of text surrounded by two square brackets. They do not come by default in WordPress, but when installing WooCommerce it includes the ones that I am going to explain to you below.
So in this blog post, we are going to learn and share Woocommerce shortcodes to make your work faster and easier.
What is Woocommerce Shortcodes?
A shortcode is a programming shortcut, a code that executes instructions of a longer code, which is usually included in the plugin, in the active theme’s functions.php file, or in your own plugin customizations.
They are shortcuts that allow you to show visualizations or special pages in your online store, which by default are not visible to the naked eye.
All Woocommerce Shortcodes
WooCommerce Page Shortcodes
The most used shortcodes in WooCommerce are for pre-built pages.
Here are the shortcodes for pre-built pages in Woocommerce:
1. Cart page: [woocommerce_cart]
- To add to cart: [add_to_cart id=”product_ID”]
- Add to cart URL: [add_to_cart_url id=”product_ID”]
2. Checkout page: [woocommerce_checkout]
3. Order tracking: [woocommerce_order_tracking]
4. My account: [woocommerce_my_account]
Woocommerce Checkout Shortcode
Checkout is a necessary page or element for every online store. Without checkout, you can’t sell anything.
Here is the shortcode for checkout to make it easy to show to your buyers:
Shortcodes for Products in Woocommerce
They need little explanation, right? Well, here you have the most used to show one or more products to the user on the web, whether they are featured, on sale, the best sellers, the best valued… or the ones you need!
Show a product: [product]
- [product id=”ID”] – Where ID is the identifier of the product.
- [product sku=”SKU”] – Where SKU is the code that we have indicated when creating the product.
Show various products: To do this, you can use WooCommerce product shortcodes with parameters, also known as attributes.
Here are the most used:
[on_sale]: offers the products that are on sale or discounted. Never use it in conjunction with the best_selling or top_rated attributes (neither can be combined).
[best_selling_products]: Obviously, this attribute refers to the best-selling products from your store.
[top_rated]: the products with the highest ratings.
[recent_products]: Latest products uploaded to an eCommerce store.
[featured_products]: Featured products, are the ones you mark as favorites in the list of products. With a star.
[sale_products]: Discounted or sold products.
[top_rated_products]: Products with the most reviews or social proof.
Related Products Shortcode
You can also change the limit number according to your needs. For example, if I want to show 9 related products then I should add a shortcode like this [related_products limit=”9″].
Product Categories Shortcodes
Yes, there are also shortcodes to define the categories of products that you want to incorporate in each space of your e-commerce. In addition, they are very simple and not only to incorporate but to remember! If you want to incorporate products from a specific category:
- [product_category] – To display products in a specified product category.
- [product_categories] – To display all your product categories.
Woocommerce Product Attributes
The attributes are added inside the brackets, distinguish between putting product when it is one product and products when there are two or more, you can use all of these:
- Skus – Comma separated list of product SKUs. For example: [product skus=”32,95,99,38,91″], to put more separated by commas.
- Category – Comma separated list of category IDs. Example:[product category=”Disney”], you can use both the ID and the name.
- Order – Indicates whether the order of the product is ascending (ASC) or descending (DESC), using the method set in order. The default value is ASC. Example: [products category=” Disney, pokemon” order=” DESC”]
- Class – Adds an HTML tag class so you can style that product with custom CSS. Example: [products class=”quick-sale”]
- Limit – Limit the number of products to display. The default is -1 (show all) when listing products, and -1 (show all) for categories. Example: [products limit=3]
- Columns – The number of columns to display. The default value is 4. Example: [products columns=”4″]
So these are the attributes for Woocommerce.
Woocommerce Shortcodes are just heaven for online store owners. With this list of Woocommerce Shortcodes, you can easily make your product page more useful and user-friendly.
Make sure to take a preview before making your products live to confirm all Woocommerce Shortcodes are working properly.
I hope this list of Woocommerce Shortcodes helps you make your online store more beautiful, easy to use, and user-friendly. If you have any questions or suggestions, don’t hesitate to leave your comment below.