Created
January 24, 2022 03:43
-
-
Save vandanojan/004c85e725adc8fe9740f58ef336ff88 to your computer and use it in GitHub Desktop.
Displaying the number of products sold in Woocommerce
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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