AI-generated WordPress plugin

Generate a WooCommerce order export to CSV plugin

Exporting orders from WooCommerce to CSV sounds trivial until you need to do it daily for a partner who expects specific column names, in a specific order, with line items expanded in separate rows. At that point the built-in export (Tools → Export) is not enough, Advanced Order Export For WooCommerce (free) gets you most of the way, and the pro version asks for €60/year for scheduled export and remote destinations.

A generated plugin is the right tool when your CSV format is fixed by a third party (a fulfilment warehouse, a tax authority, an accounting SaaS) and you want zero manual steps. You describe the columns with their exact names, the filters for which orders to include, and where the file goes — local folder, email attachment, SFTP upload, or an S3 bucket.

5 min to ZIP 24 h live sandbox WP Coding Standards

Why generate it instead of installing an existing plugin?

The free Advanced Order Export is excellent for interactive exports with a UI. It becomes awkward when the export needs to be fully automated at 06:00 every day with no human involvement, and the CSV needs to land on an SFTP server with a specific filename pattern. That falls into the pro territory, and even there the destination options are fixed.

Third-party fulfilment partners frequently send you a CSV spec they will not deviate from: columns in order X, date format Y, quantity column with no decimals, line items exploded into N rows per order. Writing a plugin that matches the spec exactly is cleaner than post-processing a generic CSV with a second script.

For shops that already have an S3 / DO Spaces bucket, pushing the CSV directly there is one API call away — no need for the fulfilment partner to have access to your server. A generated plugin can do this out of the box with whatever credentials you store in options.

Example prompt

This is the kind of description that generates this plugin. You can start from it and tweak whatever you need before hitting generate.

Plugin name: Acme WC Partner Export

Daily cron at 06:00 server time: export all orders with status "completed" placed the previous day.

CSV columns (exact order, comma separator, UTF-8 BOM):
order_id, order_date (YYYY-MM-DD), customer_email, customer_name, shipping_address1, shipping_postcode, shipping_country, sku, qty, unit_price_ex_vat, line_total, order_total, coupon_codes (pipe-separated).

Line items: one row per product. qty and amounts decimals with a dot, 2 decimals.

Destination: upload via SFTP to sftp://partner.example.com/uploads/ with filename acme-<YYYYMMDD>.csv.
SFTP credentials stored in options (host, port, user, password, remote path).

On success: log to an option with the timestamp + row count.
On failure: fire action "acme_export_failed" with the error, send admin email.

Admin: page showing the last 30 days of exports (success/fail + row counts), a "run now" button.

HPOS-compatible via wc_get_orders() with date_query.

What the generated plugin typically includes

  • WP Cron event scheduled on activation, cleared on deactivation and uninstall
  • Orders queried with wc_get_orders (HPOS-safe)
  • CSV writer using PHP fputcsv with UTF-8 BOM for Excel compatibility
  • SFTP upload via phpseclib (bundled in vendor/) with host key verification
  • Admin log page with a manual "run now" button gated by manage_woocommerce
  • Fallback to local storage if SFTP is unreachable, admin notified
  • Hooks for extending columns or filtering rows

Different column sets, different schedules, different destinations (email, S3, Google Drive via service account), multiple parallel exports — all doable.

Frequently asked questions

Can I export to Google Sheets instead of CSV?

Yes. We bundle the Google API client, authenticate with a service account (credentials stored as option), and append rows to a sheet you specify. Ask for it in the prompt and provide the spreadsheet ID.

How does this handle HPOS?

We use wc_get_orders() and $order->get_meta() throughout. No get_post_meta on orders. The plugin declares compatibility with custom_order_tables in before_woocommerce_init.

What if my shop has 5,000 orders per day?

The cron runs the export in chunks of 500 orders to avoid PHP memory limits. For truly high volume, ask for Action Scheduler integration — it spreads the work over the day and retries failed chunks automatically.

Can I trigger the export manually from the admin?

Yes, there is a "Run now" button on the admin page. It runs synchronously for immediate feedback (capped at 2,000 orders) or queues a background job for larger exports.

Ready to generate your plugin?

Create a free account, verify your email, first generation is on us.

Related:WooCommerceData exportAutomationHPOS-ready