Automattic\WooCommerce\Internal\Admin
Analytics::maybe_cancel_refund_double_count_fix_on_regenerate
Cancel a running double-counted refunds fix when a full historical import starts, since that import re-imports every affected order anyway.
Method of the class: Analytics{}
No Hooks.
Returns
void. Nothing (null).
Usage
$Analytics = new Analytics(); $Analytics->maybe_cancel_refund_double_count_fix_on_regenerate( $days, $skip_existing ): void;
- $days(int|true|false) (required)
- Number of days to import; anything that is not an integer covers the full history.
- $skip_existing(true|false) (required)
- Whether the import skips already imported orders.
Analytics::maybe_cancel_refund_double_count_fix_on_regenerate() Analytics::maybe cancel refund double count fix on regenerate code WC 11.3.0
public function maybe_cancel_refund_double_count_fix_on_regenerate( $days, $skip_existing ): void {
// The Import historical data UI omits `days` for "All", so REST passes null rather than false.
// OrdersScheduler reads the same value with is_int(), so match it.
if ( is_int( $days ) || $skip_existing ) {
return;
}
$state = self::get_fresh_refund_double_count_state();
if ( self::REFUND_DOUBLE_COUNT_STATUS_RUNNING !== $state['status'] ) {
return;
}
self::update_refund_double_count_state( array( 'status' => self::REFUND_DOUBLE_COUNT_STATUS_CANCELLED ) );
as_unschedule_all_actions( self::REFUND_DOUBLE_COUNT_FIX_HOOK );
self::record_refund_double_count_fix_finished( $state, self::REFUND_DOUBLE_COUNT_STATUS_CANCELLED );
}