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 *

WordPress Post Approval Email Notification

Learn how to create a WordPress email notification system for post approvals. Customize email templates, support multiple post types, and improve user engagement with this developer-friendly guide.

JQuery Auto Hight

jQuery height change after a specific time interval

Jquery Replace specific text in all element

Scenario Imagine you have a set of elements with the class specific_class, and they all contain the phrase “old text.” You want to replace this phrase with “New text” programmatically. The Solution Here’s a simple jQuery script to achieve this: How It Works Things to Keep in Mind Extending the Script jQuery provides a quick […]

JS fetch post API Data in 5 min simple way

js fetch post API is very simple way. some line of Javascript code and boom.

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.