Skip to content

Instantly share code, notes, and snippets.

@vandanojan
Created January 24, 2022 03:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vandanojan/004c85e725adc8fe9740f58ef336ff88 to your computer and use it in GitHub Desktop.
Save vandanojan/004c85e725adc8fe9740f58ef336ff88 to your computer and use it in GitHub Desktop.
Displaying the number of products sold in Woocommerce
add_action( 'woocommerce_single_product_summary', 'wp_product_sold_count', 11 );
function wp_product_sold_count() {
global $product;
$total_sold = $product->get_total_sales();
if ( $total_sold )
echo '' . sprintf( __( 'Total Sales: %s', 'woocommerce' ), $total_sold ) . '';
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment