Visser Labs – WooCommerce Plugins

How To Schedule Exports

Overview

Store Exporter Deluxe uses the WordPress CRON (WP-Cron) engine to schedule single and recurring exports. Multiple Scheduled Exports can be configured to run at different intervals with their own filters, options and export field requirements.

Individual Scheduled Exports can be managed from the WooCommerce > Store Exports > Scheduled Exports screen.

Global Scheduled Exports settings can be managed from the WooCommerce > Store Exports > Settings > Scheduled Exports section.


Creating a Scheduled Export using the Upload to remote FTP/SFTP Export Method

Here’s a quick step-by-step tutorial on creating a new Scheduled Export that connects to an external FTP server and saves an Order export to a specific FTP directory and with a fixed export filename.

  1. Open WooCommerce > Store Export from the WordPress Administration
  2. Switch to the Scheduled Exports tab
  3. Beside the Scheduled Exports header click the Add New button
  4. Enter a title for the Scheduled Export (it is only used within the WordPress Administration)
  5. Within the Export Filters > General section set the following options:
  6. Export type to Orders
  7. Export format to Excel XLSX
  8. Export method to Upload to remote FTP/SFTP
  9. Without saving switch to the Method section
  10. Within the Export Filters > Method section set the following options:
  11. The Host field is required, this is the web address or IP address of your hosting server (e.g. 216.58.209.132 or ftp.google.com)
  12. The Port field is optional, some hosting servers require you to connect on specific ports (e.g. 2222)
  13. The Protocol field is required, you will be given different ways to connect to your  hosting server. SFTP is recommended (more secure) while FTP is still common for many hosting servers. The SFTP option may be disabled if WordPress does not have the ability to connect using SFTP. Refer to the Troubleshooting section on this page and speak with your hosting provider.
  14. The Username field is required, this is the FTP/SFTP user login. This is not your WordPress Administration User login, speak with your hosting provider as they will create you an FTP/SFTP user account.
  15. The Password field is required, this is the FTP/SFTP user password. As above, this is not your WordPress Administration User password.
  16. The File path field is optional, setting this field means you can save exports to specific directories available to the FTP/SFTP user. This file path is relative to the base directory of the FTP/SFTP user and should not contain an opening ‘/’.In simple terms, when you connect to your hosting server using a FTP File Manager (e.g. FileZilla) the base directory is the opening directory shown when you connect to your hosting server. If you wanted to save exports to a directory named ‘exports’ within the WordPress Uploads directory you would enter:wp-content/uploads/exports/
  17. The Fixed filename field is optional, setting this field overrides the default Export filename set on the Settings tab of the opening Store Export screen. This is very handy for making the export filename relevant for individual Scheduled exports and can contain Tags, for instance:weekly_orders-%date%-%time%-%random%
  18. The Transfer mode field is optional and considered an advanced option.
  19. The Timeout field is optional and considered an advanced option.
  20.  Click Publish to save the Scheduled Export

That’s it! Here’s some screenshots to better explain. 🙂

Troubleshooting

Failed scheduled exports are shown in several convenient places:

  1. under Recent Scheduled Exports on the WooCommerce > Store Exports > Scheduled Exports screen
  2. from the Recent Scheduled Export widget on the WordPress Administration Dashboard, and
  3. reported to the WooCommerce > System Status > Logs > woo_ce_… file.

We do our best to include a precise reason for failed Scheduled Exports and suggest remedies to resolve the issue. Viewing the WooCommerce logs is aimed at Advanced users.

Failed exports when exporting via FTP

Common FTP issues include:

  • ftp_put: PORT command successful – you can try setting the Transfer Mode within Scheduled Exports > Method to Passive, otherwise you need to unblock the ports on your hosting server commonly used by the FTP protocol
  • ftp_put: Failed to establish connection – you need to contact the FTP hosting provider to confirm working FTP connection details
  • Could not upload %s to %s via FTP as the temporary export Post was not created – switch to ftp_fput upload method

If the above FTP issues persist you can try switching the FTP upload method. PHP comes with two methods – ftp_put() and ftp_fput() – use the following PHP snippet to override which FTP import method is used by the Scheduled Export and CRON export engines. Here is a snippet you can use to swap the FTP method.

Failed exports when exporting via e-mail

If the Recent Scheduled Export widget shows a successful export and yet you have not received the scheduled export within your Inbox, try the following:

  • check your Inbox Spam directory
  • configure an additional e-mail recipient at another e-mail provider (e.g. @gmail.com, @outlook.com) to isolate your e-mail provider as the issue

It is common to experience mail issues on self-hosted e-mail setups where the hosting and e-mail server are located on the same physical server. This is best resolved by contacting your hosting provider.

Scheduled export e-mail of … returned false when sending to …, check if this message was received by the recipient(s)

As of the 2.1.10 Plugin release we check the response from woocommerce_mail() – or wp_mail() as a fallback – which can return false indicating there may have been an issue with sending of the Scheduled Export e-mail. There is no feedback from the WordPress mail engine so out of precaution we display a Scheduled Export error notice when this happens, it doesn’t necessarily mean that the Scheduled Export e-mail failed to be sent so if the Scheduled Export e-mail is being received by the recipient this notice can be disabled via this PHP snippet.

In the 2.1.11 Plugin release a WordPress Administration notice will be displayed on the first time a Scheduled Export e-mail returns the above false response with a prompt to ignore future Scheduled Export error notices for this type of warning.

Scheduled Export is published but not running

Common Scheduled Export execution issues include:

  • The Scheduled Export is published but there is no notice of it running within the Recent Scheduled Exports dialog
  • The Scheduled Export doesn’t run when clicking the Execute button from the Scheduled Exports screen

Note: Please see the below section What are time-dependent Scheduled Exports? before proceeding to understand how Store Exporter Deluxe’s Scheduled Export functionality integrates with WordPress.


What do the different Export Formats within the Edit Scheduled Export screen mean?

At the time of writing we support 5 different Export Formats for Scheduled Exports which decides what Store Exporter Deluxe does with the exported file. By default we save the export file to the WordPress Media for archival purchases. The different Exports Formats are listed below:

  1. Archive to WordPress Media
  2. Save to this server
  3. Send as e-mail
  4. POST to remote URL
  5. Upload to remote FTP/SFTP

Archive to WordPress Media

This Export Format takes the export file generated at the time of the Scheduled Export and saves it to the WordPress Media. You can view the contents of this export file by opening Media from the WordPress Administration menu or via the WooCommerce > Store Export > Archives screen.

Exports saved to the WordPress Media are physically saved to the WordPress Media directory configured for your WordPress site, by default this is /wp-content/uploads/… and depending on the Date Folder Indexing option on Settings > Media can be stored within sub-directories of this folder broken down by year and month (e.g. 2012/12/… or 2015/11/…).

Save to this server

This Export Format takes the export file generated at the time of the Scheduled Export and saves the resource outside the WordPress Media by providing a directory path and filename relative to the base WordPress directory (uses the WordPress Constant: ABSPATH). You cannot view the contents o this export file by opening Media from the WordPress Administration menu as this Export Method does to save exports to the WordPress Media system.

Send as e-mail

This Export Format takes the export file generated at the time of the Scheduled Export and if all required e-mail fields are set within the Method tab of the Edit Scheduled Export screen then prepares an e-mail and sends it to the provided recipient(s).

Multiple recipients can be set to receive each Scheduled Export. After an e-mail has been prepared and sent with the export file as a file attachment the physical export file is discarded from WordPress.

POST to remote URL

This Export Format takes the export file generated at the time of the Scheduled Export and uses the WordPress function wp_remote_post() to send the export file as a one-off form POST to a receiving server that is configured to accept POST files, this might be a supplier server, drop-shipping or accountant package.

Notice: This Export Format is often confused with our Upload to remote FTP/SFTP where users want to save the export file to a fixed location but misinterpret what this Export Format is intended for. This Export Format sends a POST form to the receiving server with the export file, nothing more.

Upload to remote FTP/SFTP

This Export Format takes the export file generated at the time of the Scheduled Export and depending on the Procotol selected from the Methods panel will connect to an external FTP or SFTP server and upload the export file.

The availability of different Protocols is dependent on different PHP packages – FTP and ssh2 – being available to WordPress, if we cannot detect a given PHP package then that Protocol will be disabled until it is available. Contact your hosting provider to enable missing PHP packages.

This Export Format has wide-ranging applications and supports fixed filename rules for persistent exports, for instance a static URL that a supplier reads on a daily basis.


What are time-dependent Scheduled Exports?

The Scheduled Exports feature within Store Exporter Deluxe uses the WordPress WP-CRON scheduler to schedule and execute tasks – in our case Scheduled Exports – at given times and at specific frequencies (e.g. at 9am daily).

The WP-CRON scheduler is dependent on regular screen loads, this means active site visitors viewing Posts and Pages or Users using the WordPress Administration, without this activity the WP-CRON scheduler will wait until the next screen load then execute any tasks which are due to be run. This can be problematic for users requiring a Scheduled Export to be run at a specific time at a given frequency (e.g. at 9am daily) but the given store does not receive a site visitor until 11am meaning our Scheduled Export is sent at 11am instead of the expected 9am.

In the above case where a user requires time-dependent Scheduled Exports we would advise them to configure a CRON task within their hosting panel to manually refresh WP-CRON and ensure that the Scheduled Export runs at the required time or consider triggering their Scheduled Export via a crafted WordPress Action listed below or using our CRON export engine. Contact your hosting provider for assistance configuring CRON tasks within your hosting panel.

We have recently added WP-CLI export support enabling store owners to list and trigger the execution of one-time Scheduled Exports.wp store-export listwp store-export scheduled_export –scheduled_id=000

Supported WP-CLI commands include:

  • wp store-export list
  • wp store-export scheduled_export –scheduled_id=000

Triggering a Scheduled Export via a WordPress Action

Below is an experimental solution to trigger a Scheduled Export to run immediately by passing a unique URL to WordPress. You’ll need to add a WordPress Action to your current WordPress Theme’s functions.php.

Note: Change the secret_key variable before deploying to a live store environment using this PHP snippet.


Triggering a Scheduled Export via the manual CRON export engine

You can trigger a Scheduled Export to run immediately by passing a unique URL to WordPress. This solution uses the manual CRON export engine included with Store Exporter Deluxe and does not require adding a WordPress Action to your current WordPress Theme’s functions.php

  1. Open the WooCommerce > Store Export > Scheduled Exports screen and copy down the Post ID of the Scheduled Export you want to run
  2. Open the WooCommerce > Store Export > Settings screen and within the CRON Exports section set the Enable CRON export option to Enabled
  3. Ensure the Secret Key field is filled and copy down the Secret Key value as it will be required later; the Secret Key value is case sensitive
  4. Click Save Changes to enable the CRON export engine
  5. Within a text editor prepare a URL to trigger the manual CRON export engine.In this example the Scheduled Export has a Post ID of “100” and a Secret Key value of “00000-00000-00000-00000”.WordPress Site URL: http://www.domain-store.com
    (Replace this with your WordPress Site URL)Scheduled Export Post ID: 100
    (Replace this with the Post ID of your Scheduled Export)Secret Key: 00000-00000-00000-00000
    (Replace this with your Secret Key value)http://www.domain-store.com/?action=woo_ce-cron&key=00000-00000-00000-00000&type=product&response=download&scheduled_export=100Note: The type and response arguments are required to be filled but are ignored by the CRON export engine as it uses the details from your Scheduled Export
  6. Paste the URL into your browser to trigger the export
  7. Open the WooCommerce > Store Export > Scheduled Exports screen, within the Recent Scheduled Exports dialog you should see a “Scheduled Export completed” notice

That’s it. 🙂

Was this article helpful?

Related Articles

Visser Labs – WooCommerce Plugins
  • PO BOX 4362 Gumdale QLD Australia
  • ABN: 51 604 474 213
  • We're hiring remotely!

© 2023 Rymera Web Co Pty Ltd. All Rights Reserved. ABN 51 604 474 213. All prices are in USD.