How to display WooCommerce products and categories in various ways?

Posted on Feb 21 2019 by in Uncategorized 

What is WooCommerce and why WooCommerce Shortcode is important to know?

WooCommerce is market dominated WordPress eCommerce plugins with plenty of resources in terms and plugins and forums. It is one of the choice of for any one who wants to build eCommerce site on WordPress.

WooCommerce integrates seamlessly with WordPress using various hooks and shortcodes which helps to control the out put of eCommerce functionality. WooCommerce comes with several shortcodes that can be used to insert content inside posts and pages.

WooCommerce consists of mainly 4 pages.

  • [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

So you can create any of the pages and create them with any name by inserting the shortcode which mentioned above respectively.

Now lets say you like to create a page where you can display order tracking feature.

[woocommerce_order_tracking]

Product's shortcode:

The [products] shortcode allows you to display products by post ID, SKU, categories, attributes, with support for pagination, random sorting and product tags, replacing the need for multiples shortcodes such as:  ,  [featured_products][sale_products][best_selling_products][recent_products][product_attribute], and [top_rated_products]

To show products from specific categories:

  • [product_category] – Will display products in a specified product category.
  • [product_categories] – Will display all your product categories.

Note: above code is just an example here is the sample short code which display category name "Cates" with 4 column and 12 products on a page.

[product_category category="peanuts" per_page="12" columns="4" orderby="date" order="desc"]

Display products randomly

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

Display featured products

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

Best selling products

[products limit="3" columns="3" best_selling="true"]

Newest products

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

Specific categories [More than one]

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

Alternatively, I only want to display products not in those categories. All I need to change is the cat_operator to NOT IN

[products limit="8" columns="4" category="hoodies, tshirts" cat_operator="NOT IN"]
Attribute Display

[products columns="3" attribute="season" terms="warm" orderby="date"]
Alternatively, if I wanted to display exclusively cold weather products, I could add NOT INas my terms_operator:
[products columns="3" attribute="season" terms="warm" terms_operator="NOT IN"]