Display best selling products is the way to increase your sale and attract the customers by displaying them hot products of a store. An store owner can get a good increase in revenue by demanded product or what people buy most in a store. wooCommerce enhancing and supporting store owners to display different kind of product (hot selling, most popular or best selling). We have shared two ways to display woocommerce best selling products via shortcode and other way is to display popular products in wooCommerce programmatically using php.
Why to Show Popular Products in wooCommerce:
Most popular products helps customer to checkout the best items other people are buying on store. By display the recently sold products help to increase your store revenue to grow and you can increase your sale of online store or business.
wooCommerce earlier versions have no best selling product shortcode except product shortcode along with they introduce best_selling=true parameter. Now they have introduce the shortcode to show best selling products.
[best_selling_products] can be use.
Parameters of the Shortcode [best_selling_products]:
Parameters could be use to enhance the product display like limit, columns, order, category.
- Limit: Show how many product could be displayed.
limit = "5"
- Columns: Display how many columns
- Order: Display Ascending or Descending of products.
order = "DESC"
- Category: Display products by category example below.
category = "shirts"
Best Selling Products by Category:
Use the shortcode as below and add a parameter naming your category.
Get Best Selling Products Programmatically using PHP:
wooCommerce have the ability to read database structure to retrieve top sold products in eCommerce. Most of them ask about wooCommerce best selling products query. Read how to get popular products programmatically via PHP code. we have add some of the explanation to get you the products which are most sale.
<?php $args = array( 'post_type' => 'product', 'meta_key' => 'total_sales', 'orderby' => 'meta_value_num', 'posts_per_page' => 1, ); $loop = new WP_Query( $args ); while ( $loop->have_posts() ) : $loop->the_post(); global $product; ?> <div> <a href="<?php the_permalink(); ?>" id="id-<?php the_id(); ?>" title="<?php the_title(); ?>"> <?php if (has_post_thumbnail( $loop->post->ID )) echo get_the_post_thumbnail($loop->post->ID, 'shop_catalog'); else echo '<img src="'.woocommerce_placeholder_img_src().'" alt="product placeholder Image" width="65px" height="115px" />'; ?> <h3> <?php the_title(); ?> </h3> </a> </div> <?php endwhile; wp_reset_query(); ?>
How this snippet works?
We are using wp_query to build up the query to get products and for argument we use “meta_key” of “total_sales” and orderby “meta_value_num”. This will filter the products by total sales.
WP_Queryto query yes it’s possible since woocommerce uses custom post-type for adding products.
Tips Asked by Users – Popular Products wooCommerce
[best_selling_products] is the shortcode to display most selling products in wooCommerce.
[best_selling_products category=”tshirts”] is use to show products most sold by category.
Lower version 3.2 have the
[products] shortcode with an extra attribute of best_selling=”true” parameter. So the code could become.
A store could increase their sale by displaying top selling products. Just like super store put products on eye level to attract customers same like top selling products or popular product capture the audience and sale could be increased.