One of my current projects has been developing an eCommerce site in WordPress for a client. One of their requirements is having all orders exported nightly and then sFTP’d to their fulfillment center.
We’re using the WooCommerce plugin for their eCommerce needs, which so far has proven to be excellent and flexible enough to meet their requirements.
For this specific requirement, I modified a WooCommerce plugin to export the orders to a CSV file, which was easy enough. But I then had to modify that plugin so that I could call it from a nightly cron script.
Turns out, that is pretty simple to do. At first I thought I might have to fake logging into the site using curl and cookies, and then call the script and push through a GET request.
I then found this blog post over at CodeGarage.com which addressed the exact same issue, and he outlined a much simpler solution:
- Include wp-load.php
- Inlcude wp-admin/admin-functions.php
- Call the function
So basically, all I had to do was extricate the actual function which exported the CSV from the plugin, put it in a new PHP file, include those aforementioned files, and then I was all set.
The last step was setting up a cronjob to run /usr/bin/php on the script which was simple enough.




Hey Jon,
We’re currently working with the CSV export function plugin and we’re having a bit of trouble tryign to modify it. Trying to make a simple mod so that we can export the file by product (SKU)
we’ve tied making a few mods to it but dont think we’re getting very far as we’re having toruble trying to populate a drop down.
Would you be able to help us?