• Resolved tpipta

    (@tpipta)


    Hello,

    First off, thanks for a killer product. It’s been awesome working with it.

    Onto this situation that has been perplexing me a bit today. We wrote a small snippet of code to display the total aggregated amount of all donations for the year. It by all accounts works and has displayed the demo transactions fine. When we went into to delete those fictitious transactions, the total value still remains the total sum ever completed, but not the current amount if that makes sense. Any insight or help would be greatly appreciated!

    Thanks,
    Tony

    Snippet:

    <?php
    	$output = '<div class="goal-progress">';
    	$stats = new Give_Payment_Stats;
    	$earnings_today = $stats->get_earnings( 0, 'this_year', false );
    	//Goal Progress Text
    	$output .= '<div class="raisedHome">';
    	$output .= sprintf(
    		_x( '%s of %s raised', 'This text displays the amount of income raised compared to the goal.', 'give' ),
    		'<span class="incomeHome">' . give_currency_filter( give_format_amount( $earnings_today ) ) . '</span>',
    		'<span class="goal-textHome">$100,000</span>');
    	$output .= '</div>';
    
    	//Goal Progress Bar
    	$progress = round(($earnings_today / 100000) * 100);
    	$color = '#003e7e';
    	$output .= '<div class="progress-bar">';
    	$output .= '<span style="width: ' . esc_attr( $progress ) . '%;';
    	if ( ! empty( $color ) ) {
    		$output .= 'background-color:' . $color;
    	}
    	$output .= '"></span>';
    	$output .= '</div><!-- /.progress-bar -->';
    
    	$output .= '</div><!-- /.goal-progress -->';
    
    	echo $output;
    ?>

    https://www.ads-software.com/plugins/give/

Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Author Matt Cromwell

    (@webdevmattcrom)

    Hi there,

    Deleting transactions is problematic. Generally, it’s better to change the status to “Abandoned” or “Cancelled” rather than delete them. But we also don’t have the logic exactly right to update the totals correctly when transactions are deleted. It’s kind of a really complex issue and we made some good progress on it in the last release — your results would be REALLY strange right now if you were on the previous release. But we still have a ways to go to get that working exactly right.

    So the only way to update that now is to do so via the database. Look in the postmeta table for _give_earnings and you’ll have to update those values.

    Wish I had better news for you. Thanks for your encouragement about Give and your support.

    Thread Starter tpipta

    (@tpipta)

    Thanks for the super quick and genuine reply. We’ll remove the information from the database and hopefully it won’t really be an issue in the future anyways!

    Plugin Author Matt Cromwell

    (@webdevmattcrom)

    Sounds good!

    If you’re enjoying using Give and have appreciated our support we’d love a kind review from you here:
    https://www.ads-software.com/support/view/plugin-reviews/give

    Thanks!

    Well shucks – I ran into this issue too when deleting my test transactions. I don’t have a script, but trying to get my income to date to show correctly. No database experience…sorry. Created a new post about it because it was different enough but hoping you can assist.

    Their solution worked perfectly. Just bear in mind there is an hour cache that has to expire before you see the results. Best thing I can tell you would be to brush up on the usage of phpmyadmin.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Custom query not updating total value when transaction is removed’ is closed to new replies.