WordPress.org

Forums

[resolved] Getting correct Sum to show up on Danko Theme Fundraising Counter (6 posts)

  1. latvianalaskan
    Member
    Posted 2 years ago #

    Got a complicated question!

    On our website: coastalfootprint.org

    There is a big and proud counter for the funds that have been raised. While it is awesome, it is doubling our total on us (giving us a false sense of accomplishment!)

    Here is what I found for the outputs for the numbers:

    '<?php
    global $wpdb;
    $querystr = "SELECT SUM(mc_gross) FROM " . $wpdb->prefix . "paypal_transactions";
    $pageposts = $wpdb->get_results($querystr, ARRAY_A);
    $transaction_sum = $pageposts[0] ["SUM(mc_gross)"];
    $transaction_sum = round($transaction_sum,0);
    $transaction_sum_str =(string)$transaction_sum;
    $transaction_array = str_split($transaction_sum_str);'

    The thing is, the "paypal_transactions" table that it is pulling its sum from has "completed" and "pending" entries - the pending doesn't get deleted when a transaction is completed. So, for instance, if a person donates $100, the resulting sum would spit out $200, because the formula is totaling both the "completed" and "pending" transaction entries. But I don't have a clue on how to change the formula to just total the "completed" transactions.

    Any ideas?

  2. esmi
    Forum Moderator
    Posted 2 years ago #

    I'm sorry but as you are using a commercially supported theme, you need to seek support from the theme's developers. We only support themes downloaded from wordpress.org.

  3. latvianalaskan
    Member
    Posted 2 years ago #

    esmi - thanks for the information! I did get this theme outside of wordpress.org but there are specific sections throughout the back-end where the creators specify what is/isn't okay to edit - I am under the opinion that the section I am referring to is editable. At any rate (for those poor souls looking for knowledge scrapes) here is what I implemented to get the right SUM to show up:

    ''SELECT SUM(mc_gross)'
    . ' FROM wp_paypal_transactions'
    . ' WHERE payment_status=\'Completed\''
    . ' GROUP BY payment_status';'

  4. splendoradam
    Member
    Posted 2 years ago #

    i have this same problem. thanks for posting the code that makes it work. I'm not totally understanding your syntax, so i may repost for some guidance if i can't get it working... thanks again.

  5. Andrew
    Forum moderator & snail smusher
    Posted 2 years ago #

    You ought to discuss your findings in your own thread because this is marked resolved.

  6. splendoradam
    Member
    Posted 2 years ago #

    to other poor souls: on header.php, replace line 180 with

    $querystr = ("SELECT SUM(mc_gross) FROM wp_paypal_transactions  WHERE payment_status='Completed'  GROUP BY payment_status");

    and in front-page.php, replace line 230 with the same.
    works great!

Topic Closed

This topic has been closed to new replies.

About this Topic