'orders-export-overview', 'title' => __('New export for your ERP', 'ai-eshop-optimizer'), 'description' => __('Send orders to your accounting system as a CSV, in the exact column order it expects. Choose the period and the statuses to include, map each field once, and the same shape comes out every time — which is what stops the monthly import being re-done by hand.', 'ai-eshop-optimizer'), )); echo $aieo_oe_open; if (class_exists('AIEO_Order_Store') && !AIEO_Order_Store::hpos_readable()) { echo \Rooster\Admin\States::state('not-set-up', array( 'title' => __('Requires WooCommerce HPOS (high-performance order storage). Activate it under WooCommerce → Settings → Advanced → Features.', 'ai-eshop-optimizer'), 'href' => admin_url('admin.php?page=wc-settings&tab=advanced§ion=features'), 'label' => __('Open settings', 'ai-eshop-optimizer'), )); } echo rooster_admin_card_section_html( __('Where the file will be saved', 'ai-eshop-optimizer'), array( 'id' => 'aieo-card-orders-export-where-the-file-will-be-saved', 'description' => __('Stable canonical path under uploads/exports/. Downstream partners (ERPs, reconciliation scripts, etc.) get the same URL every run; the file is overwritten in place. Cache-busting on the LINK below uses ?v= so a refreshed link always serves fresh content even though the filename never changes.', 'ai-eshop-optimizer'), ) ); ?>

exported_orders.csv
exported_orders.csv

' . '' . esc_html(isset($last_result['filename']) ? $last_result['filename'] : 'exported_orders.csv') . ' ' . '— ' . esc_html__('open file', 'ai-eshop-optimizer') . ' ↗'; $bits = array(); if (!empty($last_result['rows_processed'])) { $bits[] = sprintf( esc_html__('%d orders processed', 'ai-eshop-optimizer'), (int) $last_result['rows_processed'] ); } if (!empty($last_result['first_id'])) { $bits[] = sprintf( esc_html__('range #%1$d → %2$s', 'ai-eshop-optimizer'), (int) $last_result['first_id'], !empty($last_result['last_id']) ? '#' . (int) $last_result['last_id'] : esc_html__('end', 'ai-eshop-optimizer') ); } if (!empty($last_result['completed_at'])) { $bits[] = sprintf( esc_html__('completed %s ago', 'ai-eshop-optimizer'), esc_html(human_time_diff(strtotime($last_result['completed_at'] . ' UTC'))) ); } if (!empty($last_result['etag'])) { $bits[] = 'etag ' . esc_html($last_result['etag']) . ''; } $aieo_oe_last = \Rooster\Admin\Ui::notice( $aieo_oe_last_link, 'success', array( 'id' => 'aieo-card-orders-export-last-export', 'title' => __('Last export', 'ai-eshop-optimizer'), 'inline' => true, 'detail' => '

' . wp_kses_post(implode(' · ', $bits)) . '

' . '

' . esc_html__('The file path is stable — only the link below carries a ?v= token so cached browsers and CDNs always fetch the latest content on refresh.', 'ai-eshop-optimizer') . '

', ) ); echo $aieo_oe_last; ?>
1) ? __('Pre-filled from your last export.', 'ai-eshop-optimizer') : ''; ?> 'aieo-dmm-orders-first', 'label' => __('Starting order ID', 'ai-eshop-optimizer'), 'help' => $aieo_oe_first_help, 'control' => $aieo_oe_ui::input('first_order_id', (string) (int) (isset($last_first_id) ? $last_first_id : 1), array('id' => 'aieo-dmm-orders-first', 'type' => 'number', 'short' => true, 'min' => '1', 'required' => true, 'help' => '' !== $aieo_oe_first_help)), )) . $aieo_oe_ui::field_row(array( 'id' => 'aieo-dmm-orders-last', 'label' => __('Ending order ID (optional)', 'ai-eshop-optimizer'), 'control' => $aieo_oe_ui::input('last_order_id', (string) (int) (isset($last_last_id) ? $last_last_id : 0), array('id' => 'aieo-dmm-orders-last', 'type' => 'number', 'short' => true, 'min' => '0')), )) . $aieo_oe_ui::field_row(array( 'id' => 'aieo-dmm-orders-format', 'label' => __('Format', 'ai-eshop-optimizer'), 'control' => $aieo_oe_ui::select('format', array('csv' => 'CSV', 'xml' => 'XML'), 'csv', array('id' => 'aieo-dmm-orders-format', 'short' => true)), )) . $aieo_oe_ui::field_row(array( 'id' => 'aieo-dmm-orders-cache-mode', 'label' => __('Cache-busting strategy', 'ai-eshop-optimizer'), 'control' => $aieo_oe_ui::select('cache_mode', array( 'stable_url' => __('Stable URL (recommended — matches meta-connector)', 'ai-eshop-optimizer'), 'version_query' => __('Stable URL + ?v= for CDNs', 'ai-eshop-optimizer'), 'unique_filename' => __('Unique filename per run', 'ai-eshop-optimizer'), ), 'stable_url', array('id' => 'aieo-dmm-orders-cache-mode')), )); ?>
__('No order statuses available.', 'ai-eshop-optimizer'), 'compact' => true)); } else { $aieo_oe_statuses = $aieo_oe_ui::checks('statuses', $selectable_statuses, array_map('strval', (array) $selected_statuses), array('inline' => true)); } $aieo_oe_statuses_row = '
' . $aieo_oe_ui::field_row(array( 'id' => 'aieo-dmm-orders-statuses', 'label' => __('Order statuses to export', 'ai-eshop-optimizer'), 'group' => true, 'control' => $aieo_oe_statuses, 'help' => empty($selectable_statuses) ? '' : __('Only orders with a ticked status are exported. Default is Completed only — so abandoned/draft carts (and other in-flight orders) are kept out of the ERP file. Tick more statuses if your ERP needs them.', 'ai-eshop-optimizer'), )) . '
'; echo $aieo_oe_statuses_row; $aieo_oe_why = \Rooster\Admin\Guidance::text(__('“Stable URL” overwrites the same file on every run at exported_orders.csv / .xml so existing ERP consumers keep working. If your CDN caches aggressively, switch to “+ ?v=” which appends a content-hash token without changing the filename. “Unique filename” produces orders-export-.csv each run — use only if downstream explicitly expects a fresh URL.', 'ai-eshop-optimizer')); echo $aieo_oe_why; ?> 'aieo-dmm-orders-job', 'state' => 'idle', 'run' => __('Start export', 'ai-eshop-optimizer'), 'run_attrs' => array('form' => 'aieo-dmm-orders-start-form', 'data-action' => 'aieo_dmm_orders_export_start'), )); echo $aieo_oe_job; ?> 'orders-export-field-map', 'icon' => 'table-properties', 'title' => __('Order field map', 'ai-eshop-optimizer'), 'description' => __('Set once, then hide. Tick to include a field and edit the CSV header name. Reorder by dragging rows.', 'ai-eshop-optimizer'), 'tools' => '', 'footer' => \Rooster\Admin\States::save_button('aieo-card-orders-export-field-map-form', array('label' => __('Save field map', 'ai-eshop-optimizer'), 'attrs' => array('id' => 'aieo-dmm-orders-fields-save'))), )); echo $aieo_oe_open; ?> (string) $job['job_id'], 'created' => (string) $job['created_at'], 'status' => (string) $job['status'], 'processed' => number_format_i18n((int) $job['processed']) . ' / ' . number_format_i18n((int) $job['total']), 'done' => (int) $job['processed'], 'filename' => (string) $job['filename'], 'url' => is_array($params) && isset($params['public_url']) ? (string) $params['public_url'] : (is_array($params) && isset($params['url']) ? (string) $params['url'] : ''), 'path' => is_array($params) && isset($params['path']) ? (string) $params['path'] : '', ); } AIEO_Table::card(array( 'anchor' => 'orders-export-recent-exports', 'icon' => 'list', 'heading' => 'h2', 'title' => __('Recent order exports', 'ai-eshop-optimizer'), 'description' => __('The order exports run lately, with when each one ran and how it ended.', 'ai-eshop-optimizer'), 'page_id' => 'orders_export', 'row_key' => 'job_id', 'rows' => $aieo_oe_rows, 'caps' => array('search' => true), 'filters' => array(array('key' => 'status', 'label' => __('Status', 'ai-eshop-optimizer'), 'kind' => 'values', 'control' => 'select')), 'per_page' => 0, 'empty' => __('No exports yet.', 'ai-eshop-optimizer'), 'columns' => array( array('key' => 'created', 'label' => __('Created', 'ai-eshop-optimizer'), 'nowrap' => true), array('key' => 'status', 'label' => __('Status', 'ai-eshop-optimizer'), 'type' => 'badge'), array('key' => 'processed', 'label' => __('Rows', 'ai-eshop-optimizer'), 'sort_key' => 'done', 'nowrap' => true), array('key' => 'filename', 'label' => __('File', 'ai-eshop-optimizer'), 'type' => 'link', 'format' => array('href' => 'url', 'external' => true)), array('key' => 'path', 'label' => __('Path', 'ai-eshop-optimizer'), 'type' => 'code'), ), 'actions' => array( array('id' => 'delete', 'label' => __('Delete', 'ai-eshop-optimizer'), 'class' => 'rooster-admin-button rooster-admin-button--sm aieo-dmm-delete-export-job', 'description' => __('Removes this job from the list and deletes its file.', 'ai-eshop-optimizer')), ), )); ?>