Automattic\WooCommerce\Admin\RemoteInboxNotifications

TotalPaymentsVolumeProcessor::process()publicWC 1.0

Compare against the store's total payments volume.

Method of the class: TotalPaymentsVolumeProcessor{}

No Hooks.

Return

true|false. The result of the operation.

Usage

$TotalPaymentsVolumeProcessor = new TotalPaymentsVolumeProcessor();
$TotalPaymentsVolumeProcessor->process( $rule, $stored_state );
$rule(object) (required)
The rule being processed by this rule processor.
$stored_state(object) (required)
Stored state.

TotalPaymentsVolumeProcessor::process() code WC 8.7.0

public function process( $rule, $stored_state ) {
	$dates           = TimeInterval::get_timeframe_dates( $rule->timeframe );
	$reports_revenue = $this->get_reports_query(
		array(
			'before'   => $dates['end'],
			'after'    => $dates['start'],
			'interval' => 'year',
			'fields'   => array( 'total_sales' ),
		)
	);
	$report_data     = $reports_revenue->get_data();

	if ( ! $report_data || ! isset( $report_data->totals->total_sales ) ) {
		return false;
	}

	$value = $report_data->totals->total_sales;

	return ComparisonOperation::compare(
		$value,
		$rule->value,
		$rule->operation
	);
}