Total of all fundraisers?

Hi,

Can anyone help point me in the right direction? I need to somehow get the total of all fundraisers into the post meta, so I can have a running total in a widget. Thanks for your help!

  • Timothy
    • Chief Pigeon

    Hey there.

    I actually thought there was an option for this but I can’t locate it…

    So I’m going to move this over as a feature request and mark it for the developer. I could see many sites wanting this to promote the total they have raised for the cause.

    Before marking it for the developer lets discuss a few simple options.

    – Total from – Total from a specific date, from the beginning of the day, week and month

    Anything else simple which you think would be handy? Maybe an arg for the username of a member? Or something to list the fundraisers from a user?

    Cheers.

  • Timothy
    • Chief Pigeon

    Sure, you will find the values in the _postmeta tables for your site. In a multisite each site will have a _postmeta table.

    They carry a meta_key of wdf_transaction.

    You would need to loop through, get the values and then run your calculations to sum them up.

    If this isn’t something you could do then perhaps the guys over at Tweaky might be able to assist further:

    https://tweaky.com

    Take care.

  • Cole
    • The Incredible Code Injector

    Sorry for not chiming in earlier.

    There is a function I wrote just for this that you can access anywhere in either a theme or plugin.

    In the main fundraising class there is a function called get_amount_raised which you can access like so.

    global $wdf;
    $amount = $wdf->get_amount_raised({$Fundaisier_Post_ID});

  • Cole
    • The Incredible Code Injector

    Timothy just pointed out to me that you were looking for the totals of all your fundraisers not just one. This should do what your looking for.

    <?php

    // Check to see if our total has been generated or saved in the recent past.
    $total = get_transient('wdf_pledge_totals');

    // If no transient was found we will generate one
    if(!$total) {
    // Get our global $wdf class ready to use. Set our initial total to zero
    global $wdf;
    $update_total = 0;

    // Get all published fundraisers
    $funders = get_posts(array('post_type' => 'funder','numberposts' => -1,'post_status' => 'publish'));

    // If we have fundraisers to look at then cycle through them all and add the totals
    if($funders) {
    foreach($funders as $funder) {
    $update_total = $update_total + (int)$wdf->get_amount_raised($funder->ID);
    }

    // Set our transient data to be stored for 12 hours.
    // This will prevent your server having to make this call everytime for your widget
    set_transient('wdf_pledge_totals', $update_total, 60*12);

    // Redeclare the $total variable so we can echo it below
    $total = get_transient('wdf_pledge_totals');
    }
    }
    echo $total;
    ?>

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.