WooCommerce Webhooks Using Claris Connect
You can use Claris Connect to create a flow to handle incoming updates from WooCommerce such as new orders or customer updates. This is a much simpler process than using the supplied PHP files for the FileMaker Data API as you don't need to worry about hosting the php files and dealing with web servers and PHP configuration changes etc. You can setup a new Claris Connect Flow in a few minutes which can receive updates from WooCommerce and create new Order records or update existing customer records.
For information on the supported versions of FileMaker Server/FileMaker Cloud and other minimum requirements please see our Claris Connect Webhooks FAQ article.
In the following example we will show you how to create a Claris Connect flow to receive new order notifications from WooCommerce (similar to the webhookNewOrder.php file). You can also adapt this for other supported webhooks such as order updates and new customer/customer updates.
To setup a new Claris Connect Flow to have new WooCommerce Orders pushed automatically to your fmEcommerce Link (WooCommerce Edition) file:
1. login to Claris Connect and create a new Project and give the Project a Name (e.g. New WooCommerce Orders)
2. click the Webhooks button on the left to create a new Webhook that we can use for receiving incoming orders
Click the Create a webhook button to create a new Webhook for your Project
2. you will then be prompted to enter a webhook name that will appear in the URL. Enter your preferred name (e.g. newWooCommerceOrder) and click the Create button:
A new webhook will be created showing the URL for this webhook:
Make a note of the URL and copy this somewhere else as you will need to enter this into your WooCommerce store Webhooks settings.
3. now that the webhook has been created click the Flows button on the left to create a new flow for this webhook. Search for HTTP in the list of triggers:
Click on the HTTP app that appears which takes you to the Incoming HTTP Request screen. You will then be prompted to choose the Webhook from the drop down list. You should see the webhook you created earlier:
You now need to test the webhook trigger by creating a webhook on the WooCommerce site for a new order. You can follow the WooCommerce instructions on how to setup Webhooks – make sure you select the appropriate option for the Topic (e.g. for the New Order webhook select Order Created for the Topic) and enter the Claris Connect Webhook URL in the Delivery URL field. Once you have created and saved the Webhook it should look something like this:
After clicking the Save webhook button WooCommerce will send a request to the Claris Connect Webhook URL to confirm that it is responding correctly. N.B. this request is not a replica of a new order webhook so you will need to enter a test order in WooCommerce later on so we have a full new order webhook to map the incoming data to. Once Claris Connect has received the webhook request from WooCommerce the Save Trigger button will become active - click the Save Trigger button to continue:
5. you now need to add another action to the Claris Connect Flow which will create a new record in the Orders table in the fmEcommerce Link (WooCommerce Edition) file and populate the relevant fields with data from the incoming order. Click the + button and select Action to add a new Action:
In the list of apps search for 'FileMaker' and select the appropriate option for where your copy of fmEcommerce Link (WooCommerce Edition) is hosted:
After selecting the appropriate Claris FileMaker option choose the Create record option and click Continue:
6. you will then be prompted to authenticate with your Claris FileMaker server (the process is slightly different for each option):
You can use the same FileMaker account that the PHP files use here as they have the required access privileges for receiving incoming messages via the Data API. After you have successfully authenticates click the Continue button:
7. you then need to choose the FileMaker layout to use - select the WebOrders layout which is the same layout the PHP files use and has the necessary fields:
Before we can continue with the field mapping from the WooCommerce order webhook payload with the FileMaker Orders table fields you will need to enter a new WooCommerce Order to trigger the webhook with actual order data. N.B. in our experience it can sometimes take a few minutes for WooCommerce to send the webhook request to Claris Connect so please make sure you wait a few minutes.
To map the WooCommerce Order data from the incoming webhook to the matching FileMaker field click the blue icon to the right of the following fields and select the option from the list (you should see the data from your test order you just entered in WooCommerce):
You only need to map the following fields:
We are replicating the same behaviour as the webhookNewOrder.php file - a new record is created in the Orders table, the _kf_WooCommerceID field is populated with the WooCommerce ID and the WebhookOrderJSON field is populated with the complete body of the webhook JSON data.
Click the Save button - your Flow should now show the following 2 actions:
8. We now need to add another Action to perform a FileMaker script after the new Order record has been created by the webhook. Click the + button to the right of the Create record action and select Action:
We are going to select the same FileMaker app that we used for the previous action. Select your FileMaker Server that was previously created which should appear under Your Apps and click Continue:
Select the Execute script option and click Continue:
Select the WebOrders layout again and the Process Webhooks Order script (same as the PHP file version). For the Script parameter we are going to pass in the WooCommerce Order ID which you can select from the webhook payload as you previously did by clicking the blue icon to the right of the Script parameter field:
Click the Save button - your Flow should now show the following 3 actions:
You can now toggle the Disabled option to Enabled - you will receive the following prompt:
Click Save to make your Flow active. You can now test this is working successfully by entering another test order on your WooCommerce store and you should see the new order created and the data for the order populated into the appropriate fields.