> For the complete documentation index, see [llms.txt](https://learnphp.gitbook.io/learnphp/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://learnphp.gitbook.io/learnphp/wordpress/how-to-show-the-number-of-products-sold-on-woocommerce-stores-imageskincare.vn-ok.md).

# How to show the number of products sold on WooCommerce stores imageskincare.vn (ok)

https\://storepro.io/learn/how-to-show-the-number-of-products-sold-on-woocommerce-stores/

## How to show the number of products sold on WooCommerce stores

[![](https://secure.gravatar.com/avatar/8615df644130b4152d48cf55fd7d02e1?s=96\&d=mm\&r=g) Hashim Puthiyakath](https://storepro.io/learn/author/hashim/)  October 30, 2020![How to show the number of products sold on WooCommerce stores](https://storepro.io/wp-content/uploads/2020/10/How-to-show-the-number-of-products-sold-on-WooCommerce-stores-770x400.png)[BLOG](https://storepro.io/category/blog/), [TECHNICAL](https://storepro.io/category/technical/), [WOOCOMMERCE](https://storepro.io/category/woocommerce/)

Showing the number of times a product has been ordered is helpful to improve conversion on eCommerce sites. It is a great social proof for the customers.

In this blog, we show you two methods to display the number of products sold on the single product page on a WooCommerce site.

**Table of Contents**

1. [How to display product sold count with code snippet](https://storepro.io/learn/how-to-show-the-number-of-products-sold-on-woocommerce-stores/#how-to-display-product-sold-count-with-code-snippet)
2. [Open functions.php file](https://storepro.io/learn/how-to-show-the-number-of-products-sold-on-woocommerce-stores/#open-functions-php-file)
3. [Copy the following code snippet](https://storepro.io/learn/how-to-show-the-number-of-products-sold-on-woocommerce-stores/#copy-the-following-code-snippet)
4. [Add the code snippet to functions.php file](https://storepro.io/learn/how-to-show-the-number-of-products-sold-on-woocommerce-stores/#add-the-code-snippet-to-functions-php-file)
5. [Customize the Total Sold text](https://storepro.io/learn/how-to-show-the-number-of-products-sold-on-woocommerce-stores/#customize-the-total-sold-text)
6. [Save the changes](https://storepro.io/learn/how-to-show-the-number-of-products-sold-on-woocommerce-stores/#save-the-changes)
7. [How to display product sold count with a plugin](https://storepro.io/learn/how-to-show-the-number-of-products-sold-on-woocommerce-stores/#how-to-display-product-sold-count-with-a-plugin)
8. [Install the plugin](https://storepro.io/learn/how-to-show-the-number-of-products-sold-on-woocommerce-stores/#install-the-plugin)
9. [Configure the plugin](https://storepro.io/learn/how-to-show-the-number-of-products-sold-on-woocommerce-stores/#configure-the-plugin)
10. [Summary](https://storepro.io/learn/how-to-show-the-number-of-products-sold-on-woocommerce-stores/#summary)

There are two methods to display the number of products sold on WooCommerce stores: one using a plugin and the second by adding a code snippet to the functions.php file.

### How to display product sold count with code snippet <a href="#how-to-display-product-sold-count-with-code-snippet" id="how-to-display-product-sold-count-with-code-snippet"></a>

Showing the number of products sold by adding a PHP code snippet to **functions.php** may seem quite overwhelming if you don’t have experience with coding. But it is a simple and risk-free process if you follow the steps correctly.

* Open functions.php file

Open the WordPress admin dashboard and go to **Appearance > Theme Editor** to open the **WordPress Theme Editor**.

On this page, you can see the list files in your active theme under Template files on the right side of the page.

Scroll through the list of files to find the **functions.php file**. Once you see it, click on it to open it on the Text Editor in the middle of the page.

* Copy the following code snippet

There are two code snippets below. The first one can be used to display the number of products sold on the single product page and the second code snippet can be used to display the count of products sold on the shop page.

**Code snippet to show total sales on a single product page**

\
`// Show Total Sales on Product Page`\
`add_action( 'woocommerce_single_product_summary', 'wp_product_sold_count', 11 );`\
`function wp_product_sold_count() {`\
&#x20; `global $product;`\
&#x20; `$total_sold = $product->get_total_sales();`\
&#x20; `if ( $total_sold ) {`\
&#x20;  `echo '<p>'. sprintf(__('Total Sold: %s','woocommerce'), $total_sold). '</p>';`\
&#x20; `}`\
`}`

**Code snippet to show total sales of each product on the shop page**

\
`// Show Total Sales on Product Loop Pages (Shop, Category, etc.)`\
`add_action( 'woocommerce_after_shop_loop_item', 'shop_product_sold_count', 11 );`\
`function shop_product_sold_count() {`\
&#x20; `global $product;`\
&#x20; `$total_sold = $product->get_total_sales();`\
&#x20; `if ( $total_sold ) {`\
&#x20;  `echo '<p>' . sprintf(__('Total sold: %s','woocommerce'),$total_sold). '</p>';`\
&#x20; `}`\
`}`

* Add the code snippet to functions.php file

#### Add the code snippet to functions.php file <a href="#add-the-code-snippet-to-functions-php-file" id="add-the-code-snippet-to-functions-php-file"></a>

After copying the code snippet from above, go to the WordPress Theme Editor screen where you have the functions.php file opened.

Go to the end of the functions.php file and paste the code snippet at the end.

You can add both code snippets or anyone you wish depending on your requirements.

* Customize the Total Sold text

If you want to change the Total Sold text something different, you can change it by making one small change in the code you added to the functions.php file.

If you look at the code snippet, you can see Total Sold at the bottom of both code snippets. You can change it to anything you wish. Please remember that you shouldn’t remove the single quote symbol before the word Total.

* Save the changes

Once you make the changes, click on the Save file button to save the new changes you made in the function.php file. Now if you go to your online store, you can see the new element added to your WooCommerce store.

### How to display product sold count with a plugin <a href="#how-to-display-product-sold-count-with-a-plugin" id="how-to-display-product-sold-count-with-a-plugin"></a>

If you are not comfortable with changing the code manually on your WooCommerce store, it is recommended to use a plugin to show the total number of products sold. In this blog, we use the **WPB Show Product Sales Number for WooCommerce** plugin by **wpbean** to achieve our goal.

* Install the plugin

Open the WordPress admin dashboard of your WooCommerce store and go to Plugins > Add New.\
In the search field, enter “WPB Show Product Sales Number for WooCommerce” and hit the enter key on your keyboard to start the search. Find the plugin by wpbean and install it. Once the installation complete, activate the plugin.

* Configure the plugin

Once the plugin is activated, go to **Settings > WooCommerce Show Sales** from the left sidebar on the WordPress admin dashboard.

The settings are divided into two pages: **General Settings** and **Style Settings**.

Under the General Settings, you can manage the style and placement of the new element that shows the total sales.

On this page, you can also disable showing the count if the product sale is 0.

The settings are simple and self-explanatory. After changing the settings, click on the Save Changes button to save the changes.

On the Style Settings page, you can change the colour of the count and adjust the font size. Moreover, if you are familiar with CSS, you can also add CSS code to customize the style of the element the way you want.

After making changes on this page, don’t forget to click on the **“Save Changes”** button.

### Summary <a href="#summary" id="summary"></a>

Showing the total number of products sold is a great way to persuade customers to make a purchase. It is social proof that shows the customer that other people also buy this product, so the product must be useful. Although WooCommerce doesn’t offer any default feature to display the count of products sold, it is not that difficult to configure. We hope that the two techniques we showed above will help you to display the number of products sold on WooCommerce stores.
