Automattic\WooCommerce\Internal\Admin\Schedulers
OrdersScheduler::record_failed_order_import
Record an order ID that failed analytics import.
Deduplicates IDs. When the list exceeds FAILED_ORDER_IMPORTS_CAP, the oldest ID is dropped and the overflow counter is incremented.
Method of the class: OrdersScheduler{}
No Hooks.
Returns
null. Nothing (null).
Usage
$result = OrdersScheduler::record_failed_order_import( $order_id ): void;
- $order_id(int) (required)
- Order or refund ID that failed to import.
Changelog
| Since 11.0.0 | Introduced. |
OrdersScheduler::record_failed_order_import() OrdersScheduler::record failed order import code WC 11.0.1
public static function record_failed_order_import( $order_id ): void {
$order_id = absint( $order_id );
if ( ! $order_id ) {
return;
}
$failed = self::get_failed_order_imports();
if ( in_array( $order_id, $failed['ids'], true ) ) {
return;
}
$failed['ids'][] = $order_id;
$ids_count = count( $failed['ids'] );
while ( $ids_count > self::FAILED_ORDER_IMPORTS_CAP ) {
array_shift( $failed['ids'] );
++$failed['overflow'];
--$ids_count;
}
update_option( self::FAILED_ORDER_IMPORTS_OPTION, $failed, false );
}