WooCommerce Order Notification
N8N

WooCommerce Order Notification

A very simple n8n workflow that gets the number of 'processing' orders from your WooCommerce store using the REST API and displays them on your AWTRIX display.
A flow by Brian Lovelace

Download flow

Flow Details

A very simple n8n workflow that gets the number of 'processing' orders from your WooCommerce store in 5 minute increments using the REST API and displays them on your AWTRIX display.

There is additional functionality in the app with a true/false trigger. If the number of orders that it pulls in equals zero, then it will remove the app from displaying on the AWTRIX pixel clock. If the number of orders is not zero, it will show the number orders in the format "{# of processing orders} new" — feel free to adjust this as you wish.

Step 1: WooCommerce Credentials

This uses n8n's built-in WooCommerce authorization, so simply create app credentials in your WordPress Dashboard under WooCommerce > Settings > Advanced > REST API then add those credentials to n8n.

Additional credentials details: For the app credentials, ensure that your user is an Administrator or Shop Manager, and that you give it Read/Write permissions. Copy the Consumer Key and the Consumer Secret and add it to your Credentials in n8n. The credentials tab is on the left. Click into it and hit "Add Credential." On top of the Key & Secret, you will need to add your store URL, and ensure that "Include Credentials in Query" is ticked to the on position.

Step 2: Changes in n8n Specific to your Website

Once you do that, make sure that in this n8n workflow, you go to the "Get Processing Order Data" and change them to your own credentials. At the same time, you will see this under URL "https://yourstoreaddresshere.com/wp-json/wc/v3/orders" — ensure you change the domain in the string to your own.

For the final n8n step, make sure to go the "Send to Clock" and "Remove from Clock" steps and make sure that the URL is accurately set to the local IP address of your clock.

Make sure to save and Activate the workflow.

Step 3: Adding the Icon to Your Clock

Lastly, go to the IP address of your clock in your browser, hit the 'Icons' tab, and paste in "3039" (without quotation marks) under Lametric Icon ID, and hit Download.

Customizations

Alternative Icon Choices

If you want to see or use alternative Lametric Icons, you can go to https://developer.lametric.com/icons and find one that you like or create your own. Once you do either of these things you can go into the flow, go to "Send to Clock" and change the ID of the Icon under Body Parameters > Icon (name) > Value

Time Between Data Updates

You can adjust the time between triggers by selecting the first step of the Workflow named "Every 5 Minutes" and change the "Minutes Between Triggers" value. Please remember that the more often that you trigger this, the more taxing this becomes on your WordPress server.

Always Display the Number of Pending Orders (Even if Zero)

If you'd like to do this, simply delete the IF node of the n8n sequence and reconnect "Parse Code" to "Send to Clock." If you do this, I recommend keeping "Remove from Clock" and disconnected from all other nodes if you'd ever like to deactivate the Workflow and manually remove the app from your clock. Alternatively, you can remove the app from your clock by deactivating the n8n workflow and rebooting your clock by accessing http://[Clock IP]/api/reboot from your browser.

{ "name": "Show Number of Processing WooCommerce Orders on AWTRIX Clock", "nodes": [ { "parameters": { "method": "POST", "url": "http://192.168.1.255/api/custom", "sendQuery": true, "queryParameters": { "parameters": [ { "name": "name", "value": "woo-orders" } ] }, "sendBody": true, "bodyParameters": { "parameters": [ { "name": "text", "value": "={{ $json.results }} NEW" }, { "name": "icon", "value": "3039" } ] }, "options": {} }, "id": "922fbeb0-57fe-4a44-b54d-9398847c8f2d", "name": "Send to Clock", "type": "n8n-nodes-base.httpRequest", "typeVersion": 4.1, "position": [ 1320, 180 ] }, { "parameters": { "url": "https://yourstoreaddresshere.com/wp-json/wc/v3/orders", "authentication": "predefinedCredentialType", "nodeCredentialType": "wooCommerceApi", "sendQuery": true, "queryParameters": { "parameters": [ { "name": "status", "value": "processing" } ] }, "options": {} }, "id": "fa0730d3-b5d9-4ac5-9d78-f43d834bfa40", "name": "Get Processing Order Data", "type": "n8n-nodes-base.httpRequest", "typeVersion": 4.1, "position": [ 600, 80 ], "alwaysOutputData": true, }, { "parameters": { "jsCode": "\nif (Object.keys(items[0].json).length === 0) {\n return [\n {\n json: {\n results: 0,\n }\n }\n ]\n}\nreturn [\n {\n json: {\n results: items.length,\n }\n }\n];" }, "id": "4517643d-d095-4c67-8535-dbaf380cb252", "name": "Parse Code", "type": "n8n-nodes-base.code", "typeVersion": 1, "position": [ 800, 80 ] }, { "parameters": { "rule": { "interval": [ { "field": "minutes" } ] } }, "id": "34b72bbd-728b-4829-b067-bb4b38c26615", "name": "Every 5 Minutes", "type": "n8n-nodes-base.scheduleTrigger", "typeVersion": 1, "position": [ 400, 80 ] }, { "parameters": { "conditions": { "number": [ { "value1": "={{ $json.results }}", "operation": "equal" } ] } }, "id": "17b53ead-ec7f-4677-b470-11639699a307", "name": "IF", "type": "n8n-nodes-base.if", "typeVersion": 1, "position": [ 1000, 80 ] }, { "parameters": { "method": "POST", "url": "http://192.168.1.255/api/custom", "sendQuery": true, "queryParameters": { "parameters": [ { "name": "name", "value": "woo-orders" } ] }, "options": {} }, "id": "8b6a2a6f-5883-452b-bef1-3b02146764d0", "name": "Remove from Clock", "type": "n8n-nodes-base.httpRequest", "typeVersion": 4.1, "position": [ 1320, -20 ] } ], "pinData": {}, "connections": { "Get Processing Order Data": { "main": [ [ { "node": "Parse Code", "type": "main", "index": 0 } ] ] }, "Parse Code": { "main": [ [ { "node": "IF", "type": "main", "index": 0 } ] ] }, "Every 5 Minutes": { "main": [ [ { "node": "Get Processing Order Data", "type": "main", "index": 0 } ] ] }, "IF": { "main": [ [ { "node": "Remove from Clock", "type": "main", "index": 0 } ], [ { "node": "Send to Clock", "type": "main", "index": 0 } ] ] } }, "active": true, "settings": {}, "versionId": "b0341d37-5a71-41ae-b10e-f9c48c333043", "id": "3", "meta": { "instanceId": "fad48ee50ab295e27486d400f427ed5b50baff0c1dc235dc9413ccebae5358c7" }, "tags": [] }
-- Flow first published on June 12, 2023, last updated on June 12, 2023 at 06:33.