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

It’s very important to get the trust from your customer when you are doing online business. Showing the number sold on your woocommerce site can improve the confidence when your customer intend to place the order.It’s very helpful to improve conversion on your woocommerce landing page.

  1. Find functions.php document and add the code

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

';
}

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

';
}

Add these code snippet to the end of functions.php, save and quit.

2. Install a plugin to show the number sold in your woocommerce store

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

Leave a Comment