WooCommerce Number of Downloads

I’m developing a WordPress / WooCommerce driven shop which is used only for people to sign up and publish virtual downloadable products. Is there any way to track the amount of times a user’s product has been downloaded (uniquely)? I literally have no idea where to start looking for a solution for this so if anyone could help me out that’d me awesome. Thanks!

Related posts

Leave a Reply

2 comments

  1. you can get it by function total_sales, but when your users can download items more than once, it is necessary to combine with download permissions

  2. Use code below:

    add_action( 'woocommerce_single_product_summary', 'custom_product_sold_count', 11 );
    
    function custom_product_sold_count() {
       global $product;
       $units_sold = $product->get_total_sales();
       if ( $units_sold ) echo '<p>' . sprintf( __( 'Units Sold: %s', 'woocommerce' ), $units_sold ) . '</p>';
    }