December 28, 2024
1 min read
Essential Code Snippet For Web Developers

Every time we are going to build an E-Commerce store with WooCommerce we all need to use shortcode.

Basic Store setup shortcode

We need put this shortcode to different pages and then those pages are ready to link with WooCommerce plugin

Page Shortcode
[woocommerce_cart] – shows the cart page
[woocommerce_checkout] – shows the checkout page
[woocommerce_my_account] – shows the user account page
[woocommerce_order_tracking] – shows the order tracking form

Product page shortcode

With this shortcode we can show different type of product on any page as we want

Product Shortcode
[featured_products] 
[sale_products]
[best_selling_products]
[recent_products]
[product_attribute]
[top_rated_products]
[best_selling]
[on_sale]

Product shortcode attribute

There is an opportunity to customize how your product appears on the page. You just need to put some extra value with your past shortcode.

If you want to display one row with 4 product

[products limit="4" columns="4" orderby="popularity" class="quick-sale" on_sale="true" ]

If you want to display my featured products, two per row, with a maximum of four items.

[products limit="4" columns="2" visibility="featured" ]

Newest Products

If you want to display the newest products first – four products across one row.
To accomplish this, we’ll use the Post ID (which is generated when the product page is created), along with the order and order by command.
Since you can’t see the Post ID from the frontend, the ID#s have been superimposed over the images.

[products limit="4" columns="4" orderby="id" order="DESC" visibility="visible"]

Specific Categories

If you only want to display hoodies and shirts, but not accessories. I’ll use two rows of four.

[products limit="8" columns="4" category="hoodies, tshirts" cat_operator="AND"]

Paginations

Display product with pagination. 4 product per page

[recent_products limit="12" columns="4" paginate="true"]

Reference: https://docs.woocommerce.com/document/woocommerce-shortcodes/

Leave a Reply

Your email address will not be published. Required fields are marked *

Get WooCommerce product info

Show product info in the place as you wish to. It help you to make your custom woocommerce product page layout.

Remove WooCommerce checkout fields

Remove WooCommerce Checkout field with simple filter hook

WooCommerce Ajax Product Search and Category Filter Without Plugin

WooCommerce Ajax Product Search with Category Filter. Simple code, without any plugin.

JQuery Auto Hight

jQuery height change after a specific time interval

Web Development Project in mind?

if you looking for a web developer for paid contribution to your project I am available for work.

Mukto
Mukto

Click the button below to chat with me.