Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
WooCommerce display number of products sold on single product page
add_action( 'woocommerce_single_product_summary', 'wc_product_sold_count', 11 );
function wc_product_sold_count() {
global $product;
$units_sold = get_post_meta( $product->id, 'total_sales', true );
echo '<p>' . sprintf( __( 'Units Sold: %s', 'woocommerce' ), $units_sold ) . '</p>';
Copy link

i added this code to my funcitons php, but units sold just show 1 on all products. Using the latest woocommerce

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment