Site icon Experience Wordpress Developer Online – Design Develop and Maintenance Support

Show Number Of Products Sold on Single Product or Shop Page in Woocommerce

Currently your customers have no idea how many quantity or downloads have been ordered from your WooCommerce site. So in order to apply this change, Show Number Of Products Sold on Single Product or Shop Page.


So you can add below code in your theme’s functions.php file of your active child theme (or theme).

//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 ) . '

'; } //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 ) . '

'; }
Exit mobile version