WooCommerce: Show Number Of Products Sold on Product Page

WooCommerce: Show Number Of Products Sold on Product Page
Categories: Woocommerce Tips Tags: product sold, sales counter, single product page 12 Comments
Spread the Word?

Woocommerce database stores the number of products sold.

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 to show it in the product summary.

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

/**
* @snippet Show Total Sales on Product Page
* @how-to Watch tutorial @ http://businessbloomer.com/?p=19055
* @sourcecode http://businessbloomer.com/?p=315
* @author Rodolfo Melogli
* @testedwith WooCommerce 2.5.2
*/

add_action( ‘woocommerce_single_product_summary’, ‘bbloomer_product_sold_count’, 11 );

function bbloomer_product_sold_count() {
global $product;
$units_sold = get_post_meta( $product->id, ‘total_sales’, true );
echo ‘

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

‘;
}
WooCommerce Snippet: Show Total Sales on Product Loop Pages (Shop, Category, etc.)

/**
* @snippet Show Total Sales on Loop Pages
* @how-to Watch tutorial @ http://businessbloomer.com/?p=19055
* @sourcecode http://businessbloomer.com/?p=315
* @author Rodolfo Melogli
* @testedwith WooCommerce 2.5.2
*/

add_action( ‘woocommerce_after_shop_loop_item’, ‘bbloomer_product_sold_count’, 11 );

function bbloomer_product_sold_count() {
global $product;
$units_sold = get_post_meta( $product->id, ‘total_sales’, true );
echo ‘

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

‘;
}
WooCommerce Snippet: Show Total Sales on Single Product Pages & Loop Pages (Shop, Category, etc.)

/**
* @snippet Show Total Sales on Single Product + Loop Pages
* @how-to Watch tutorial @ http://businessbloomer.com/?p=19055
* @sourcecode http://businessbloomer.com/?p=315
* @author Rodolfo Melogli
* @testedwith WooCommerce 2.5.2
*/

add_action( ‘woocommerce_single_product_summary’, ‘bbloomer_product_sold_count’, 11 );
add_action( ‘woocommerce_after_shop_loop_item’, ‘bbloomer_product_sold_count’, 11 );

function bbloomer_product_sold_count() {
global $product;
$units_sold = get_post_meta( $product->id, ‘total_sales’, true );
echo ‘

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

‘;
}