This article is an example of how to create an incremental or change data source for WooCommerce REST API. Steps are similar for other REST API connectors like Magento, BigCommerce, ConnectWise etc. The outcome of this article is to export only new or recently modified WooCommerce orders to Excel.
Note: Steps are identical for SmartConnect.com, except coding needs to be in JavaScript.
Configuration Steps
1. Create two new
Global variables in SmartConnect, for example,
GBL_WOO_ORD_DATE and
GBL_WOO_ORD_STAGE_DATE. Set a default date value for GBL_WOO_ORD_DATE in the ISO8601-compliant date format (2020-06-15T07:17:39).
2. Next, go to the Maintenance > WooCommerce REST connector > Data Source tab
a. Edit the List all Orders data source.
b. Navigate to the Parameters
c. Add new parameter key modified_after with value GBL_WOO_ORD_DATE.
3. Next, create a data source for the List all Orders
a. Data Sources > Bulk > Generic REST Data Source
4. Then create an integration process using the data source and set the destination Excel export file.
Note: This process will work with any destination you choose.
5. Complete the Mapping destination of the integration.
a. You must map at least 1 field to the target.
6. Switch to the Tasks
a. Create a new Run Script task as a Task that runs before the map.
b. Write a script to read the current system date, and format the date in the required destination system date format. For this example, I have formatted the date according to the required ISO8601-compliant date format
c. Save the task.
7. Add a new Script Task to Tasks that run if the integration succeeds
a. Set the script value to update the GBL_WOO_ORD_DATE variable with the value of the GBL_WOO_ORD_STAGE_DATE
8. Next, move to the Variables tab and edit the GBL_WOO_ORD_DATE
a. Make sure the Persist Run Value
1. With this option set the value saved at the end of the map run will be used on the next run.
Conclusion
With these settings configured the integration will capture the date and time the integration run started and save it to a temporary variable. If the integration completes successfully, the value of the temporary variable will be transferred to the variable used in the REST Data Source setup so it can be used as the starting date on the next integration run.