Home » WooCommerce: Show Number Of Products Sold @ Product Page

WooCommerce: Show Number Of Products Sold @ Product Page

by adminkys

WooCommerce database already stores the number of products sold for you.

Therefore, you may want to show such number on the product page, close to the Add To Cart button. As we’ve seen in my book Ecommerce and Beyond, showing the number of sales for each product can increase your sales conversion rate.

All you need is pasting the following code in your functions.php. Enjoy!

WooCommerce: Show Total Sales on the Single Product Page
WooCommerce: Show Total Sales on the Single Product Page

PHP Snippet: Show Total Number of Sales @ WooCommerce Single Product Page

/**
 * @snippet       Show Total Sales @ WooCommerce Single Product
 * @how-to        Get tutoraspire.com FREE
 * @author        Tutor Aspire
 * @compatible    Woo 4.5
 * @donate $9     https://www.tutoraspire.com
 */
 
add_action( 'woocommerce_single_product_summary', 'tutoraspire_product_sold_count', 11 );
 
function tutoraspire_product_sold_count() {
   global $product;
   $units_sold = $product->get_total_sales();
   if ( $units_sold ) echo '

' . sprintf( __( 'Units Sold: %s', 'woocommerce' ), $units_sold ) . '

'; }

You may also like