Integrating eFORMz with Woo Commerce API
To integrate eFORMz with Woo Commerce you will need to do web service calls from eFORMz to the woo commerce rest API.
To see how to do a web service call using eFORMz please look at this article:
In order to be able to do this you will need the URL to access your data on Woo Commerce and a user with a consumer key and secret. In order to get this, work with your Woo Commerce contact.
Once you have these pieces of information you are ready to connect to the Woo Commerce API.
The Woo Commerce API allows you to connect to pull or push all kinds of data. You can retrieve information on a single order, or retrieve ALL orders that are ready for processing. You can also update the order status to Complete once the order has been processed in eFORMz.
To view the various types of info that can be retrieved, review the Woo Commerce API documentation:
http://woocommerce.github.io/woocommerce-rest-api-docs/#introduction
Once you have chosen the type of data you wish you retrieve via the API, you will need to create four Variables in the eFORMz project:
URL – used to store the URL for the instance and API call you are executing.
WebResponseData – used to store the data that is returned from the API call
WebResponseCode – used to store the API call code that is returned (200, 400, 500, etc.)
Authorization – used to store your Consumer Key and Secret.
In order to correctly call the API from eFORMz you will need to store the Consumer Key and Secret correctly as follows…..
- Set the value of the Authorization variable to your Consumer Key
- Concatenate “:”
- Concatenate your Consumer Secret.
- Encode the variable to Base64.
- Remove any instances of the string “\r\n” by doing a REPLACE.
- Insert the value “Basic” at index 0.
In the web service procedure, you need to chose the proper request verb depending on what the API call requires.
In this example we are doing a call to retrieve all open orders, so we use a GET instruction.
Here are the steps to setting up your web service call.
- Authorization = the value of the Authorization variable we just prepared
- Accept = the value of “application/json”
- User-Agent = “eFORMz/11.02.11”.
- Once you have done this chose to use a variable for the URL and use the URL variable that you have stored with the correct URL.
- Put the Output data as MIME
- Set the Response data to your WebResponseData variable.
Once you have done this add the procedure to set the variable WebResponseCode after the WebService procedure.
The data returned from the API comes back in JSON. Please look at this article on how to handle JSON in eFORMz: