Automattic\WooCommerce\Admin
ReportsSync::reset_import_stats
Update the import stat totals and counts.
Method of the class: ReportsSync{}
No Hooks.
Returns
null. Nothing (null).
Usage
$result = ReportsSync::reset_import_stats( $days, $skip_existing );
- $days(int|true|false) (required)
- Number of days to import.
- $skip_existing(true|false) (required)
- Skip existing records.
ReportsSync::reset_import_stats() ReportsSync::reset import stats code WC 10.7.0
public static function reset_import_stats( $days, $skip_existing ) {
$import_stats = get_option( ImportScheduler::IMPORT_STATS_OPTION, array() );
$totals = self::get_import_totals( $days, $skip_existing );
foreach ( self::get_schedulers() as $scheduler ) {
$import_stats[ $scheduler::$name ]['imported'] = 0;
$import_stats[ $scheduler::$name ]['total'] = $totals[ $scheduler::$name ];
}
// Update imported from date if older than previous.
$previous_import_date = isset( $import_stats['imported_from'] ) ? $import_stats['imported_from'] : null;
$current_import_date = $days ? gmdate( 'Y-m-d 00:00:00', time() - ( DAY_IN_SECONDS * $days ) ) : -1;
if ( ! $previous_import_date || -1 === $current_import_date || new \DateTime( $previous_import_date ) > new \DateTime( $current_import_date ) ) {
$import_stats['imported_from'] = $current_import_date;
}
update_option( ImportScheduler::IMPORT_STATS_OPTION, $import_stats );
}