Auto-Grabbing Order Data From SellWire

I’m going to demonstrate how to access order data programmatically from SellWire for a product. I’m going to be using this for building automation.

Why Not Use SellWire APIs?

At the moment SellWire provides no APIs, but they are planned. Until they are, some method of building automation is needed.

To do this, I’ve programmed my code to automatically log in, navigate to the orders page, and submit the export form.

Requirements

To implement the code I used the PHP-Browser library, with some modifications of my own to account for some markup errors and edge cases encountered. PHP-Browser acts as a browser object in PHP, tracking cookies, integrating with XPath, and making it easy to navigate through forms and pages.

Update: My changes have been pulled into the main PHP-Browser repository

The Code

View the code on Gist.

To use it, make a function call like so:

$csvdata = get_sellwire_csv('username','password','project_id');

To get your project ID, you’ll need to enter SellWire, and edit your product to show the model dialogue. Once in the dialog, open your browsers developer tools and find a hidden input with the nameĀ file-edit-id, its value is your project_id.

What Is This Useful For?

Many, many things, such as:

  • Automated Backups
  • Custom Alerts
  • Automatically setting up user accounts on support systems
  • Building licensing systems

You may put the code on a cron task via wp-cron, or manually add it via a button in the backend.

In a follow up post, I’ll show how to schedule grabbing data, storing it as a post type, and tracking new orders.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.