WooCommerce API nodes for Node-RED
This commit is contained in:
@@ -0,0 +1,57 @@
|
||||
[
|
||||
{
|
||||
"id": "wc-poll-trigger",
|
||||
"type": "inject",
|
||||
"name": "Poll Processing Orders",
|
||||
"topic": "woocommerce/poll",
|
||||
"payload": "",
|
||||
"payloadType": "date",
|
||||
"repeat": "900",
|
||||
"crontab": "",
|
||||
"once": false,
|
||||
"onceDelay": 0.1,
|
||||
"x": 150,
|
||||
"y": 100,
|
||||
"wires": [["wc-list-orders"]]
|
||||
},
|
||||
{
|
||||
"id": "wc-list-orders",
|
||||
"type": "woocommerce-order",
|
||||
"name": "List Processing Orders",
|
||||
"config": "woocommerce-config-placeholder",
|
||||
"operation": "list",
|
||||
"x": 350,
|
||||
"y": 100,
|
||||
"wires": [["wc-extract-info"]]
|
||||
},
|
||||
{
|
||||
"id": "wc-extract-info",
|
||||
"type": "function",
|
||||
"name": "Extract Order Info",
|
||||
"func": "var order = Array.isArray(msg.payload) ? msg.payload[0] : msg.payload;\nif (!order || !order.billing) return null;\nmsg.title = 'Order #' + order.number + ' – ' + order.billing.first_name + ' ' + order.billing.last_name;\nif (order.billing.company) msg.title += ' (' + order.billing.company + ')';\nmsg.customer = order.billing.email;\nmsg.body = 'Products:\\n';\nif (order.line_items) {\n for (var i = 0; i < order.line_items.length; i++) {\n var item = order.line_items[i];\n msg.body += '- ' + item.name + ' x' + item.quantity + ' (' + order.currency + ' ' + item.total + ')\\n';\n }\n}\nmsg.body += '\\nTotal: ' + order.currency + ' ' + order.total;\nmsg.body += '\\nAddress: ' + order.billing.address_1 + ', ' + order.billing.city + ' ' + order.billing.postcode;\nmsg.body += '\\nPhone: ' + order.billing.phone;\nmsg.body += '\\nEmail: ' + order.billing.email;\nmsg.ticketId = order.id;\nmsg.tag = 'woocommerce-order';\nreturn msg;",
|
||||
"outputs": 1,
|
||||
"x": 550,
|
||||
"y": 100,
|
||||
"wires": [["zammad-create-ticket"]]
|
||||
},
|
||||
{
|
||||
"id": "zammad-create-ticket",
|
||||
"type": "zammad-ticket",
|
||||
"name": "Create Ticket",
|
||||
"config": "zammad-config-placeholder",
|
||||
"operation": "create",
|
||||
"x": 750,
|
||||
"y": 100,
|
||||
"wires": [["zammad-add-tag"]]
|
||||
},
|
||||
{
|
||||
"id": "zammad-add-tag",
|
||||
"type": "zammad-ticket",
|
||||
"name": "Add WooCommerce Tag",
|
||||
"config": "zammad-config-placeholder",
|
||||
"operation": "addTag",
|
||||
"x": 950,
|
||||
"y": 100,
|
||||
"wires": [[]]
|
||||
}
|
||||
]
|
||||
Reference in New Issue
Block a user