WooCommerce Is a feature-rich plugin for WordPress used for the e-commerce domain. The plugin helps the user to create an online store without much hassle. It is a scalable and optimized platform for users to create their own store or create stores for other people using WordPress. A feature of the WooCommerce platform is shortcodes which are snippets or tiny bits of code and each bit of code has a unique functionality. There are a variety of shortcodes that comes with the plugin. Let’s have a look around with a proper guide to these shortcodes:
What are the types of ShortCodes and how to use them
There are a lot of options and settings like Specific Tax Setups, MaxMind Geolocation integration, and much more (Visit the official documentation for more options). One of these is the shortcodes that are included with WooCommerce. The shortcodes can be used to insert different types of content like cart information, checkout page, order tracking, and much more into pages and posts. Here are some different types of shortcodes which you can you to improve the functionality of your online store.
Product shortcodes are used to display products as well as add more functionality to the product-related search. These shortcodes can be used to display products, add images for products, add filters for product search, and much more. Have a look at some shortcodes which are commonly used for products.
[woocommerce_product_search]: This shortcode adds a search field where the customer can search for the required type of product. It will display the title of the product, a short description, and the price of the product. The customer can add the products to their cart easily with the search bar and it would look something like this:
You can use it by placing [woocommerce_procduct_search] on the WordPress editor page.
You can also use some shortcode attributes to modify these shortcodes according to your preference, for example:
[woocommerce_product_search show_description=” no” limit=”10”]
This shortcode will modify the search field where the description of the product will not be displayed and the number of products will be limited to ‘10’.
[product_category]: This is used to display the products in a specific category where we can specify the id using args or arguments in the shortcodes. Let’s say we want to create a separate category for shoes so we will be using the following shortcode:
You can also decide whether a particular product should fall and be shown in the category or not.
[products]: This one is used to display products on a page and you can use various perimeters with the shortcode to display the products according to your choice. Let’s say we want to limit the number of products that are being displayed along with the columns and we order them by their popularity, the shortcode will be:
[products limit=”5” columns=”4” orderby=”popularity” ]
‘limit’, ‘columns’, and ‘popularity’, all are attributes of the [product] shortcode.
These shortcodes are used on the cart page and display the content and the section for coupon codes. The cart shortcode can be used by adding [woocommerce_cart] anywhere in the editor. Some common shortcodes used here are:
[woocommerce_cart_totals]: This shortcode displays the total of the items present in the cart which includes the tax, shipping amount, and the total amount.
[add_to_cart]: This shortcode is used to add an add-to-cart button on the product where the user can click it and the product to their cart. It is mostly used when you don’t want to display the entire product instead, display the button. An example of the shortcode:
[woocommerce_cart_button]: This one, is used to add a “proceed to checkout” button in the cart section where the user can click the button and move to the checkout page. It is used as [woocommerce_cart_button].
These shortcodes are used to display information about the customer’s shipping address and billing address plus, the customer can choose different payment methods for the cart value. Some of the common shortcodes of this category are:
[woocommerce_checkout]: This shortcode display’s the checkout form on the user’s screen which contains the details about the billing, address, and payment options.
[woocommerce_checkout_order_review]: if you want the user to review the product which is in the cart, you can use this shortcode which displays the quantity, price, cart total, taxes, and shipping charges.
[woocommerce_checkout_login]: This shortcode renders the login page on the checkout page so that the user can log in and access their saved shipping and billing addresses.
Other than these, some more shortcodes might come in handy when creating an online store.
[woocommerce_order_tracking]: The order tracking page is not added by default when you use woocommerce. You have to use the order tracking shortcode, which takes the order id and the billing email as the input from the user and the customers can track their order. You can use it by creating a page called “order tracking” and then adding [woocommerce_order_tracking] to the content.
[woocommerce_recently_viewed]: This shortcode is used to display a list of recently viewed items to the user and is helpful for the users who want to to quickly access their previous viewed products.
Shortcodes are important as they provide the much needed functionality to an online store. These short code snippets makes it easy to add dynamic content on the store with just a few steps. You can add the shortcodes on pages and posts of WordPress, where you can paste the block in the block editor. The shortcodes can be used for product pages, checkout pages, cart pages, order tracking pages and much more. Overall, shortcodes is a powerful tool that you can you to boost the functionality of your online store.