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>';

This comment has been minimized.

Copy link

@kachmul2004 kachmul2004 commented Dec 9, 2017

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
You can’t perform that action at this time.