Quantcast
Channel: WordPress.org Forums » All Topics
Viewing all articles
Browse latest Browse all 82367

Error in sales & earnings report

$
0
0

Replies: 0

Hi, I’ve been working with the reports and I’ve had a few problems with some donations.
After a search, the problem appears to be the end date set. If you select to export sales & earnings and select a month, the donations made the last day doesn’t count.

I think the problem is in two different places:
Getting sales: class-export-earnings.php
You set the end date as:
$date2 = mktime( 0, 0, 0, $m1, cal_days_in_month( CAL_GREGORIAN, $m1, $year ), $year );
It should be:
$date2 = mktime( 23, 59, 59, $m1, cal_days_in_month( CAL_GREGORIAN, $m1, $year ), $year );

In order to get all day.

Getting earnings: post_where filter (class-payments-stats.php)
In this case, if you look into the filter function (payments_where):

if ( ! is_wp_error( $this->end_date ) ) {

			if ( $this->timestamp ) {
				$format = 'Y-m-d 00:00:00';
			} else {
				$format = 'Y-m-d 23:59:59';
			}

			$end_date = date( $format, $this->end_date );

			$end_where = " AND $wpdb->posts.post_date <= '{$end_date}'";
		}

If you pass a timestamp end_time its formatted wrong and the problem is the same, you lost all the donations made the last day of the month.

On the other hand, is there a way to delete all these give_stats_ transients? I’m trying to fix this problems using your filters but I cant’t get the correct results without deleting these transients.

Thanks in advance.


Viewing all articles
Browse latest Browse all 82367

Trending Articles