Automattic\WooCommerce\Admin\RemoteSpecs\RuleProcessors
TotalPaymentsVolumeProcessor::process
Compare against the store's total payments volume.
Method of the class: TotalPaymentsVolumeProcessor{}
No Hooks.
Returns
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() TotalPaymentsVolumeProcessor::process code WC 10.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
);
}