Displaying the WooCommerce Product Sold Count on your product pages can be a great way to showcase the popularity of your items. This tutorial will walk you through the process of adding a simple code snippet to your WordPress site to achieve this functionality.
Prerequisites
Please make sure you have the following installed and activated:
Follow these steps to display the product sold count:
- Navigate to
Snippet >
Add New
. - Name your new snippet “Show Products Sold”.
- Copy the code below:
/** * Snippet Name: WooCommerce Show Number Of Units Sold On Product Page * Snippet Author: ecommercehints.com */ add_action( 'woocommerce_after_add_to_cart_button', 'ecommercehints_show_units_sold_product_page' ); function ecommercehints_show_units_sold_product_page() { global $product; echo '<br>Units Sold: '. $product->get_total_sales(); }
Source: Code Snippets
- Paste the copied code into your new snippet.
- Save changes and Activate the snippet.
Now, when you visit a product page, the number of units sold will be displayed.
WooCommerce Product Sold Count – Conclusion
With just a few steps, you’ve successfully added a feature to your WooCommerce store that highlights the sales success of your products. This not only informs potential customers about popular items but can also encourage more sales by showcasing the demand for your products.