* : The order ID. * * @param array $args Arguments. * @return void */ public function check( $args ) { $order_id = isset( $args[0] ) ? (int) $args[0] : 0; $order = function_exists( 'wc_get_order' ) ? wc_get_order( $order_id ) : null; if ( ! is_object( $order ) ) { WP_CLI::error( 'That order was not found.' ); } $report = hawo_explain_order( get_option( 'hawo_settings', array() ), $order, hawo_trigger_for_order( $order ) ); WP_CLI::log( $report['summary'] ); } /** * List old orders that match. Does not change them. * * @return void */ public function preview() { $ids = hawo_preview_old_order_ids( get_option( 'hawo_settings', array() ) ); if ( empty( $ids ) ) { WP_CLI::log( 'No old orders matched. Nothing was changed.' ); return; } foreach ( $ids as $order_id ) { WP_CLI::log( (string) $order_id ); } } /** * Complete the old orders that match. This is the same job as the settings button. * * @return void */ public function complete() { $settings = get_option( 'hawo_settings', array() ); $ids = hawo_preview_old_order_ids( is_array( $settings ) ? $settings : array() ); $result = hawo_complete_listed_orders( $ids, is_array( $settings ) ? $settings : array() ); WP_CLI::success( sprintf( 'Updated %1$d orders. Skipped %2$d.', (int) $result['done'], (int) $result['skipped'] ) ); } } WP_CLI::add_command( 'hawo', 'HAWO_CLI_Command' );