Automattic\WooCommerce\Internal\Admin
Analytics::run_full_refund_fix_data_tool
Handles the Fix button submission for the full refund fix tool.
When the "Disable tool" action is requested (i.e. the Check confirmed no affected orders), deletes the old-data flag so the tool no longer appears. Otherwise schedules the first batch job to re-import all affected refund orders.
Method of the class: Analytics{}
No Hooks.
Returns
string. Success message.
Usage
$Analytics = new Analytics(); $Analytics->run_full_refund_fix_data_tool();
Changelog
| Since 10.8.0 | Introduced. |
Analytics::run_full_refund_fix_data_tool() Analytics::run full refund fix data tool code WC 11.3.0
public function run_full_refund_fix_data_tool() {
// phpcs:ignore WordPress.Security.NonceVerification.Recommended -- Nonce verified by WooCommerce tools framework.
if ( isset( $_GET['wc_refund_fix_action'] ) && 'disable' === sanitize_key( $_GET['wc_refund_fix_action'] ) ) {
delete_option( 'woocommerce_analytics_uses_old_full_refund_data' );
delete_option( 'woocommerce_analytics_show_old_refund_data_tool' );
return __( 'Tool dismissed.', 'woocommerce' );
}
if ( self::is_batch_pending_or_running( 'woocommerce_analytics_refund_fix_batch' ) ) {
return __( 'A fix is already in progress, please check back later.', 'woocommerce' );
}
// Clear the legacy flag before queuing so that every batch job runs with
// the corrected full-refund import logic (uses_new_full_refund_data() → true).
// Set the show-tool option so the tool stays visible until the merchant dismisses it.
delete_option( 'woocommerce_analytics_uses_old_full_refund_data' );
update_option( 'woocommerce_analytics_show_old_refund_data_tool', 'yes' );
self::schedule_batch( 'woocommerce_analytics_refund_fix_batch', array( 0 ) );
return __( 'Re-importing refunded orders in batches. Full refund data will be updated shortly.', 'woocommerce' );
}