How do I export only the new Shopify orders that were paid since the last export?

Some stores might have orders come in that aren't marked "Paid" right away. An example is when PayPal was used to pay for the order, where the payment may not get approved until a few days later (depending on country).

In this scenario, we don't want to filter the data based on when the order was created. We want to filter based on when the order was paid instead.

The Shopify API, however, doesn't have a "Paid At" field that we can simply filter by. But a workaround in EZ Exporter is to look at the transaction dates and set the settings like this (the logic here is if the order is currently in "Paid" status, then the last transaction date would be the "Paid At" date):

The first setting is to set the "Created At" filter to some reasonable date range to reduce the amount of data to request from Shopify and speed up the export process. For example, if it will never take more than 14 days for an order's payment status to switch to "Paid", then setting this filter to "Last 14 Days" would work.

Then we want to also use the following Custom Filters:

Data must match: all conditions

  • Last Successful Transaction Date is greater than or equal to {{ last_successful_run }}
  • Last Successful Transaction Date is less than {{ current_task_start_time }}

The Custom Filters happen on our end and our app will then filter the data further to only include orders where the last successful transaction is greater than or equal to the last successful run date.

The second Custom Filter handles potential race conditions where a new order in "Paid" status comes in (or an existing order gets marked as "Paid") while the export process is still running which could result in that order getting included in the current run and also in the next run.  So it's important to include this as well to prevent that.

Caveats

1. One case where this might not work is for orders created outside of Shopify's standard order creation flow.

For example, if the order data was imported into Shopify using a third-party app, that app might not have included the transaction data. Since the "Paid At" date in Shopify is based on the transaction data, those orders missing the transaction data will always get skipped.

Even if the imported order contains transaction data, this could still be an issue since the order's payment may have been captured before that order was created in Shopify. A scheduled export will miss it if a run that was meant to capture that order occurs but the order hasn't been imported into Shopify yet.

2. Another case we've seen where an order won't have any transaction data is if the order's total price is 0 (e.g. the customer used a special discount code).

For this particular case, you might want to just create a completely separate Export Profile and Data Settings specifically for these orders with the following filter settings:

  • Filters
    • Created: Since Last Successful Run
  • Custom Filters:
    • Data must match: all conditions
      • Total is equal to 0
      • Last Successful Transaction Date is blank

Related Articles:


App: EZ Exporter

Tags: shopify, advanced features, shopify orders