heduler::IMPORT_STATS_OPTION, $import_stats ); } /** * Get stats for current import. * * @return array */ public static function get_import_stats() { $import_stats = get_option( ImportScheduler::IMPORT_STATS_OPTION, array() ); $import_stats['is_importing'] = self::is_importing(); return $import_stats; } /** * Get the import totals for all syncs. * * @param int|bool $days Number of days to import. * @param bool $skip_existing Skip existing records. * @return array */ public static function get_import_totals( $days, $skip_existing ) { $totals = array(); foreach ( self::get_schedulers() as $scheduler ) { $items = $scheduler::get_items( 1, 1, $days, $skip_existing ); $totals[ $scheduler::$name ] = $items->total; } return $totals; } /** * Clears all queued actions. */ public static function clear_queued_actions() { foreach ( self::get_schedulers() as $scheduler ) { $scheduler::clear_queued_actions(); } } /** * Delete all data for reports. * * @return string */ public static function delete_report_data() { // Cancel all pending import jobs. self::clear_queued_actions(); foreach ( self::get_schedulers() as $scheduler ) { $scheduler::schedule_action( 'delete_batch_init', array() ); } // Delete import options. delete_option( ImportScheduler::IMPORT_STATS_OPTION ); return __( 'Report table data is being deleted.', 'woocommerce' ); } /** * Clear the count cache when products are added or updated, or when * the no/low stock options are changed. * * @param int $id Post/product ID. */ public static function clear_stock_count_cache( $id ) { delete_transient( 'wc_admin_stock_count_lowstock' ); delete_transient( 'wc_admin_product_count' ); $status_options = wc_get_product_stock_status_options(); foreach ( $status_options as $status => $label ) { delete_transient( 'wc_admin_stock_count_' . $status ); } } }