How To Display Item Sold Number On Your Product Page From Woocommerce Store

It’s very important to get the trust of your customer when you are doing online business. Showing the number sold on your WooCommerce store can improve the confidence when your customer intends to place an order. It’s very helpful to improve conversion on your WooCommerce landing page.

There are two methods you can display how many items were sold on your WooCommerce Store.

Add PHP codes to the “functions.php” document. The steps are as below.

Step 1, Find the “functions.php” document and add the code

Step 2, Add the Code snippet below 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() {
global $product;
$total_sold = get_post_meta( $product->id, 'total_sales', true );
if ( $total_sold ) echo '
' . sprintf( __( 'Total Sold: %s', 'woocommerce' ), $total_sold ) . '

';
}

3. Add the Code snippet below to show the 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() {
global $product;
$total_sold = get_post_meta( $product->id, 'total_sales', true );
if ( $total_sold) echo '
' . sprintf( __( 'Total Sold: %s', 'woocommerce' ), $total_sold ) . '

';
}

After you have added these code snippets to the end of “functions.php”, save and quit. You will see the item sold number on your WooCommerce Store.

Install a plugin to show the number sold in your WooCommerce store

Go to the plugin dashboard and add a new plugin from the WordPress plugin directory. Search “WPB Show Product Sales Number for WooCommerce” install and activate it.

Leave a Comment