"Sold X Times" Note Under EDD Purchase Buttons
Shows how many times a download has been bought under its purchase button, as social proof, once it passes a minimum number of sales.
Opens WPIDE on
Code
$wpide_edd_min_sales = 10; // Show the note from this many sales.
add_action( 'edd_purchase_link_end', function ( $download_id ) use ( $wpide_edd_min_sales ) {
$sales = (int) edd_get_download_sales_stats( $download_id );
if ( $sales >= $wpide_edd_min_sales ) {
printf( '<p class="wpide-edd-sales" style="margin:.5em 0 0;font-size:.9em;opacity:.8">%s</p>', esc_html( sprintf( 'Bought %s times', number_format_i18n( $sales ) ) ) );
}
} );
Notes
Hidden until a download reaches $wpide_edd_min_sales sales, so new products do not show low numbers.
How to add this snippet
- Install WPIDE on your WordPress site (it is free) and open Code Snippets.
- Use snippet above adds it from the library in one click. Or copy the code into a new snippet with the same code type.
- It is added inactive: review the code and settings, then switch it on.