Viewing 15 replies - 1 through 15 (of 29 total)
  • Thread Starter jaboli

    (@jaboli)

    is it so hard that anybody cant help me ancoluding plugin author?!!!! ??

    Plugin Contributor Pippin Williamson

    (@mordauk)

    Here’s a quick tutorial that shows how to do it: https://sumobi.com/show-a-downloads-sale-and-download-count/

    Thread Starter jaboli

    (@jaboli)

    thx for reply
    but its a funcions code
    i just need to put this code in my specific file
    after puting these code in functions.php how i can display in other file?!

    Thread Starter jaboli

    (@jaboli)

    is there any shortcode to display sales number for EDD?
    i dont want to display on widget i want display in a file!!

    Thread Starter jaboli

    (@jaboli)

    i mean how display add_action output?!!

    Thread Starter jaboli

    (@jaboli)

    <?php $query = new WP_Query( array( 'post_type' => 'download',
    'order'  => 'DESC',
    'orderby'  => 'meta_value_num',
    'meta_key'  => '_edd_download_earnings',
    'posts_per_page'  => 10
    ) );
    if ( $query ) { while( $query->have_posts() ) : $query->the_post();
    ?>
    <li><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a>
    - <?php $sales = get_post_meta( get_the_ID(), '_edd_download_sales', true ); echo ( is_null( $sales ) ? '0' : $sales ); ?> ????</li>
    
    <?php endwhile; } ?>

    this code display 10 products sales number
    i want to display specific product sales number

    If you go to this link, does it show what you are hoping to accomplish?
    https://sumobi.com/show-a-downloads-sale-and-download-count/

    Thread Starter jaboli

    (@jaboli)

    dear john as i told this code is for functions.php and i dont know how can display output of that code in other files to show sales number

    The best way to apply the code snippet to your site is to create a new custom plugin. To do that, install the free plugin called Pluginception,

    https://www.ads-software.com/plugins/pluginception/, and use it to create a new custom plugin. Name the plugin something appropriate and then paste the provided code snippet into it and activate the plugin.

    If you want it to show somewhere else (like a custom widget) you’ll need to code that into your widget’s code. You’ll need to make sure you are using the right post id for the current page.

    $sales = edd_get_download_sales_stats( get_the_ID() );
    	$sales = $sales > 1 ? $sales . ' sales' : $sales . ' sale';
    	echo '<p>';
    	echo  $sales;
    	echo '<br/>';
    	echo sumobi_edd_get_download_count( get_the_ID() ) . ' downloads';
    	echo '</p>';

    Here’s a link to get you started with finding the current post id when building your custom widget’s code:

    https://wordpress.stackexchange.com/questions/166106/how-to-get-post-id-of-the-current-page-post-inside-a-widget

    Thread Starter jaboli

    (@jaboli)

    you dont understand what i mean
    i dont think so want a hard request to you!!!!
    in EDD admin panel sales number display for each products
    i just want to display that sales number to single.php just that!!!!!
    is that so hard?!!

    Yes it is definitely possible. You just need to use the code I provided in my last response. You could put it directly in your single.php file if you’d like.

    You’d also need to make sure that you add the second chunk of code from this site to your functions.php file because it contains a custom function which is called by the first chunk of code – which again, you could place on your single.php file:
    https://sumobi.com/show-a-downloads-sale-and-download-count/

    I would recommend using a child theme if you didn’t make your own theme though because updates will overwrite your custom code changes to your theme.

    You can learn more about Child Themes here:
    https://codex.www.ads-software.com/Child_Themes

    Thread Starter jaboli

    (@jaboli)

    at first i make my own theme
    second i put this code in my single.php

    $sales = edd_get_download_sales_stats( get_the_ID() );
    	$sales = $sales > 1 ? $sales . ' sales' : $sales . ' sale';
    	echo '<p>';
    	echo  $sales;
    	echo '<br/>';
    	echo sumobi_edd_get_download_count( get_the_ID() ) . ' downloads';
    	echo '</p>';

    and also put this code in functions.php

    <?php
    /**
     * Show the number of sales and download count inside the "Download Details" widget
     */
    function sumobi_edd_show_download_sales() {
    	$sales = edd_get_download_sales_stats( get_the_ID() );
    	$sales = $sales > 1 ? $sales . ' sales' : $sales . ' sale';
    	echo '<p>';
    	echo  $sales;
    	echo '<br/>';
    	echo sumobi_edd_get_download_count( get_the_ID() ) . ' downloads';
    	echo '</p>';
    }
    add_action( 'edd_product_details_widget_before_purchase_button', 'sumobi_edd_show_download_sales' );
    /**
     * Get the download count of a download
     * Modified version of edd_get_file_downloaded_count()
     */
    function sumobi_edd_get_download_count( $download_id = 0 ) {
    	global $edd_logs;
    	$meta_query = array(
    		'relation'	=> 'AND',
    		array(
    			'key' 	=> '_edd_log_file_id'
    		),
    		array(
    			'key' 	=> '_edd_log_payment_id'
    		)
    	);
    	return $edd_logs->get_log_count( $download_id, 'file_download', $meta_query );
    }

    the output is just`
    sale
    0 downloads

    sale
    0 downloads`

    How many sales does the item have?

    Thread Starter jaboli

    (@jaboli)

    some item have sales some items dont have but all items display 0 sale!!!

Viewing 15 replies - 1 through 15 (of 29 total)
  • The topic ‘display sales number for each product’ is closed to new replies.