• Blog
  • How to Schedule Automatic Order Archiving in WooCommerce

How to Schedule Automatic Order Archiving in WooCommerce

October 4, 2026
How to Schedule Automatic Order Archiving in WooCommerce
Quick answer

Old WooCommerce orders accumulate in your database tables, slowing down your admin screens, reports, and checkout pages over time. Archiving moves completed orders out of the live tables automatically on a schedule you set, keeping your database lean while preserving order history for audits and customer disputes. By the end of this guide, you will have scheduled automatic order archiving with rules based on order status, age, and value, plus optional automatic deletion with backups.

Why Scheduled Order Archiving Matters

Archiving is not the same as deleting. When you archive an order, you move it out of the tables WooCommerce queries on every page load and every report, then store it somewhere your customers and support team can still reach it. The practical result is that a routine action like opening the Orders screen stops dragging a decade of history behind it.

Bloated databases and old orders rank among the top causes of WooCommerce slowdown especially as stores age. A typical order writes rows across four tables: wp_posts, wp_postmeta, wp_woocommerce_order_items, and wp_woocommerce_order_itemmeta. A store processing 40 orders a day reaches 14,600 orders in a year and 43,000 in three years. Each order generates dozens of metadata rows, so your wp_postmeta table grows much faster than your visible order count suggests.

Merchants managing six-figure order counts report postmeta tables exceeding 8 million rows where even simple admin queries become sluggish. Industry guidance on WooCommerce database maintenance typically recommends keeping the last 12 to 24 months of orders in the main WooCommerce tables while moving older ones into archive tables or external storage. That window covers returns, chargebacks, and warranty claims for most stores, while keeping the working dataset small enough to stay fast.

Automatic archiving stops the slowdown without losing order history or requiring monthly manual cleanup.

How to Set Up Automatic Order Archiving in WooCommerce?

The fastest path to scheduled archiving is the WooCommerce Export and Archive Old Orders plugin. It automates the entire process: define when orders should move out of your live tables, the plugin moves them on a recurring schedule, and you can export orders in CSV, XML, or JSON whenever you need a historical record for accounting or customer service.

Method 1: Automatic Archiving with the WooCommerce Archive Old Orders

Step 1: Install and Activate the Plugin

Download the .zip file from your WooCommerce account, then navigate to WordPress Admin > Plugins > Add New.

  • Click Upload Plugin and select the .zip file you downloaded.
  • Click Install Now and wait for WordPress to unpack the files.
  • Click Activate to enable the plugin on your store.

You should now see Archive Orders listed as a new tab under WooCommerce > Settings.

Step 2: Enable Auto Archiving and Set the Schedule Frequency

These settings control whether the archiving job runs automatically and how often it processes orders. Navigate to WooCommerce > Settings > Archive Orders > General.

  • Enable Auto Archiving: tick this box so eligible orders are archived on every cron run. Without this enabled, nothing automates.
  • Batch Size: the maximum number of orders processed per run. Accept values between 10 and 1000. The default is 500. Lower this on shared hosting to avoid timeouts.
  • Schedule Frequency: how often the archiving job fires. Choose from Every 30 Minutes, Hourly, Every 2 Hours, Every 6 Hours, Twice Daily, or Daily.
  • Delete DB data on deactivation: if checked, all plugin tables and settings are permanently removed when the plugin is deactivated. This action cannot be undone.

You should now see the Archive Orders settings ready for configuration across the General, Archiving Rules, Deletion & Backup, and My Account & Subscriptions tabs.

Tip: On a store with high order volume, use a smaller Batch Size paired with a more frequent Schedule Frequency. Many small runs are gentler on your server than one large nightly sweep.

Step 3: Define Per-Status Age Rules

Status rules determine how long each order status remains in your live WooCommerce tables. Navigate to Archive Orders > Archiving Rules.

  • Enabled: tick to include that status in automatic cron runs. Only enabled statuses are processed.
  • Archive Timing: the number of days after the status change date before an order with that status becomes eligible for archiving.
  • Never Archive: permanently blocks archiving for that status, overriding every other rule.
  • Add Status: use the dropdown to add extra order statuses to the rules table if your store uses custom statuses.

The default rows are Completed (365 days), Processing (30 days), On Hold (30 days), Cancelled (60 days), and Failed (30 days). Adjust these timings to match your refund window and chargeback liability period.

You should now see one archiving row per order status, each with its own timing and enabled checkbox.

Step 4: Add Value-Tier Rules for High-Value Orders

Value tiers allow you to keep expensive orders on hand longer, which matters when disputes and chargebacks tend to involve larger order amounts. In the Archiving Rules screen, scroll to the value-tier section below the status rules.

  • Min and Max: the order amount range for this tier, in your store currency.
  • Archive after (days): the number of days after the status change before an order within this value range becomes eligible for archiving.
  • Never Archive: excludes all orders matching this value range from archiving permanently.
  • Add tier: creates another row for a different amount range.

When an order matches a tier, the plugin uses whichever is longer: the status-based days or the tier-based days. Orders matching no tier follow their status timing only.

You should now see your value ranges listed as separate rows beneath the status rules.

Step 5: Protect Specific Orders with Manual Lists

Manual lists handle exceptions that automated rules cannot anticipate, such as a VIP customer's order you want preserved or a high-value transaction under active dispute. In Archiving Rules, find the manual list fields.

  • Manual Inclusion List: comma separated order IDs that are force archived on the next cron run, regardless of status or tier timing.
  • Manual Exclusion List: comma separated order IDs that are never archived, regardless of any rule.

You should now see your listed order IDs saved, and those orders will follow the inclusion or exclusion behavior on the next archive run.

Step 6: Configure Auto Deletion with Backups

Archiving moves orders out of your active tables, and deletion removes them entirely. Set up backups to protect against accidents. Navigate to Archive Orders > Deletion & Backup.

  • Enable Auto Deletion: deletes archived orders once the retention period passes.
  • Retention Days: how long an archived order is kept before deletion. The default is 730 days (two years).
  • Backup Before Delete: creates a backup file before each deletion run. Keep this enabled.
  • Backup Retention Days: how long backup files are kept before removal. The default is 365 days.
  • Deletion History: a log of all past deletion events, including the date and the number of orders removed.

You should now see the Deletion & Backup screen configured with your chosen retention and backup settings.

Warning: Auto deletion without backups is irreversible. Confirm that Backup Before Delete is ticked before you leave this screen.

Step 7: Configure Customer Access to Archived Orders

Customers sometimes request their order history months or years later. Decide now whether they can reach archived orders themselves. Navigate to Archive Orders > My Account & Subscriptions.

  • Enable My Account Tab: displays an Archived Orders tab on the customer My Account page.
  • My Account Tab Label: the text shown for that tab. The default is Archived Orders.
  • Subscription renewal order policy: how renewal orders are treated. Choose Never archive renewals, Allow only if the related subscription is cancelled, or Follow normal archive rules when eligible.

You should now see the Archived Orders tab available (or hidden) based on your choice, and the tab label appears as you configured it.

Step 8: Verify the First Archive Run

After your first cron run completes, verify that the rules you set behave as intended. Navigate to WooCommerce > Archived Orders.

  • Use the status tabs to filter by All, Pending Payment, Processing, On Hold, Completed, Cancelled, Refunded, Failed, Draft, or Archived.
  • Use the date range pickers and order search field, then click Filter to narrow results.
  • Each row shows Order Number, Date, Customer, Status, Total, and an Archived On date.
  • View opens full order details, Unarchive returns the order to your main orders list, and Delete removes it permanently.
  • Bulk Actions applies these to multiple archived orders at once.

You should now see an Archived Orders list populated with the first batch of moved orders.

Method 2: Manual Archiving with Code and WordPress Cron

If you want total control over archiving logic, or if your hosting agreement limits plugin installation, you can build order archiving yourself using WordPress Cron and custom PHP. This approach is not for beginners. It assumes you are comfortable editing code and testing database queries on a staging copy first.

Warning: Never test archiving logic on a live store. Order archiving touches wp_posts and wp_postmeta tables. A mistake can remove order data that customers or your accountant still need. Use a staging copy first.

Step 1: Register a Custom Cron Interval and Schedule the Event

WordPress Cron only includes hourly, twice daily, and daily intervals out of the box. For tighter archiving loops, declare a custom interval first. Add a filter on the cron_schedules hook that returns an array with your interval name, duration in seconds, and a display label. Then use wp_schedule_event() to register a recurring task.

  • Wrap the scheduling call in a check for wp_next_scheduled() so duplicate events do not stack on every page load.
  • Hook into plugin or theme activation and deactivation to create and remove the schedule automatically.
  • Use a namespaced hook name like mystore_archive_old_orders to avoid collisions.

You should now see your custom interval listed in wp_get_schedules() output, and a single scheduled event under your hook name in tools like WP Crontrol.

Step 2: Write the Archiving Function

The archiving function queries for orders matching your criteria, copies them into an archive table, then marks them as archived or deletes them. Keep the logic explicit and testable.

  1. Query for orders using wc_get_orders() with an array return type, filtering on order status, a date_created cutoff, and a limit to prevent timeouts on large datasets.
  2. Loop the results and copy each order's fields and meta into your archive table using $wpdb->insert() with a prepared statement.
  3. Only after the insert succeeds, update the order's status to a reserved value for archived records, or delete the rows if your policy allows it.
  4. Log the count of processed orders to an option or a custom log file so you can verify each run completed.

Process orders in batches to prevent PHP timeout. A single unbounded query on a store with tens of thousands of orders will fail.

You should now have a function that, when triggered manually, moves a defined batch of orders and reports how many it handled.

Step 3: Test the Schedule Before Trusting Production

A cron job that silently fails is worse than no cron job, because you will assume your database is being cleaned when it is not.

  • Trigger the hook manually using WP Crontrol or the wp cron event run WP-CLI command and watch for PHP errors.
  • Compare the order count before and after the run against the number your function reported.
  • Confirm your archive table exists with the expected columns and that a sample record matches the original order.
  • Verify that a customer's account page still displays their order history correctly.
Tip: Because WordPress Cron only fires when visitors reach your site, low-traffic stores should replace WP-Cron with a real server-side cron entry pointing at wp-cron.php, otherwise your schedule drifts unpredictably.

You should now see consistent, repeatable results across two or three consecutive test runs with no errors in your logs.

How to Verify Your Archive Schedule Is Running

Scheduling archiving is only half the job. If the cron job silently fails, orders stay in your main tables while you assume they are gone. Here is how to confirm the schedule actually runs.

Start with the plugin's own activity. Go to WooCommerce > Archived Orders and check the Archived On column on the newest rows. If the most recent timestamp is older than your chosen schedule frequency, the job is not completing.

Next, check your WordPress Cron system. WooCommerce relies on WP-Cron, which only fires when someone visits your site. On low-traffic stores this delays archiving for hours. Install WP Crontrol to inspect scheduled events and run the archive hook manually. If your host disables WP-Cron and uses a real server cron instead, confirm the entry exists in your hosting control panel.

Finally, compare order counts before and after a run. Check the order status totals on WooCommerce > Orders and cross-reference them against the archived side. If counts on the main list drop but archived counts do not rise, check whether Enable Auto Deletion is removing orders instead. If nothing moves, confirm the relevant status is Enabled under Archiving Rules and not marked Never Archive.

Troubleshooting Common Archiving Issues

If no orders get archived after several days

WordPress schedules tasks through WP-Cron, which only fires when visitors reach your site. On a low-traffic store, a quiet overnight stretch means the archiving run never starts. Check Tools > Site Health for warnings about scheduled events, then confirm your host is not blocking loopback requests. If traffic is steady but nothing moves, verify you enabled the relevant status under Archiving Rulessince a disabled status is skipped entirely on each run.

If archiving stops partway through the batch

Processing thousands of orders at once exhausts PHP memory or hits a script timeout, leaving the run incomplete. Lower the Batch Size setting on the General tab so each run processes fewer orders, then let the schedule catch up over several cycles. Pair a smaller batch with a longer Schedule Frequency on resource-constrained hosting.

If archived orders seem to have disappeared

Nine times out of ten they are still there, just hidden behind a filter. Open WooCommerce > Archived Ordersset the status tabs back to Alland clear the date range pickers. A leftover date filter from an earlier search is the most common reason the list looks empty. If the list is genuinely empty, review your Manual Exclusion List in the Archiving Rules tab for order IDs you may have added during testing.

If backup fails before deletion

Automatic deletion depends on Backup Before Delete staying enabled, and backups need free disk space plus write access to your uploads directory. If backups fail, disable Enable Auto Deletion until you fix the underlying problem, so no orders are removed without a safety copy. Check available disk space, clear old backup files, and verify write permissions on your uploads folder. If permissions look correct and backups still fail, contact your host, as some managed plans restrict long-running write operations.

Conclusion

WooCommerce archive old orders transforms database maintenance from a monthly chore into a background task that runs on your schedule. By moving old orders out of your active WooCommerce tables, you keep your admin screens, reports, and checkout pages fast, while retaining complete order history for audits, chargebacks, and customer service. The Export and Archive Old Orders plugin handles all of this through settings screens, with no coding required. Set your rules once, enable the schedule, and let it run in the background while your store stays lean.

Frequently Asked Questions

Can I archive orders that are still processing or on hold?+–
Yes. The plugin allows per-status archiving rules, so you can archive Processing and On Hold orders if their age exceeds your chosen threshold. Many stores archive these statuses quickly since they represent failed payments or cancelled checkouts. Enable the status in Archiving Rules and set your preferred age threshold.
What happens to a customer's order history if I archive their orders?+
If you enable the My Account Tab option in the My Account & Subscriptions settings, archived orders appear in a separate tab on the customer's account page. Otherwise, archived orders are hidden from their view. Either way, you retain full access to the order data for support or refund purposes.
Can I export archived orders as a backup?+
Yes. The plugin exports archived orders as CSV, XML, or JSON. Before deletion runs, you can also enable Backup Before Delete to automatically create a backup file. These backups are retained for a configurable period, defaulting to 365 days.
Will archiving break my accounting or tax software integration?+
Archiving moves orders into separate tables, which may affect custom reporting queries or third-party integrations that expect all orders in the main WooCommerce tables. Test on a staging copy first. If an integration fails, you can temporarily disable auto archiving, unarchive orders using the Unarchive button, or export the archived orders and import them into your accounting system separately.
What happens to renewal orders if I use WooCommerce Subscriptions?+
The Subscription renewal order policy setting in My Account & Subscriptions lets you choose how renewal orders are handled. You can never archive them, archive only if the related subscription is cancelled, or follow your normal archiving rules. Choose based on whether your support team needs quick access to renewal order history.

Share Article

  • support widget30-day money back guarantee
  • support widgetDedicated Support Team
  • support widgetSafe & Secure Free Update
  • support widgetSafe Customized Solutions