WooCommerce

Describe the issue/error/question

My workflow is meant to do the following:

  • Order details received via form entry through webhook
  • After parsing and creating the order in WooCommerce, the HTTP node retrieves each line item as JSON and the lists node splits them into items before they are parsed via the code node
  • Woo1 adds each as a line item
  • Woo2 then sets the order to processing

What’s happening is:

  • Order gets created
  • First line item returned gets added
  • Workflow halts

Any ideas why it’s messing up the order ID in the path for the subsequent items, and/or how I can better structure the workflow to fix this?

What is the error message (if any)?

{"context":{},"name":"NodeApiError","cause":{"message":"404 - {\"code\":\"rest_no_route\",\"message\":\"No route was found matching the URL and request method.\",\"data\":{\"status\":404}}","name":"Error","stack":"Error: Request failed with status code 404\n    at createError (/usr/local/lib/node_modules/n8n/node_modules/axios/lib/core/createError.js:16:15)\n    at settle (/usr/local/lib/node_modules/n8n/node_modules/axios/lib/core/settle.js:17:12)\n    at IncomingMessage.handleStreamEnd (/usr/local/lib/node_modules/n8n/node_modules/axios/lib/adapters/http.js:269:11)\n    at IncomingMessage.emit (node:events:525:35)\n    at endReadableNT (node:internal/streams/readable:1358:12)\n    at processTicksAndRejections (node:internal/process/task_queues:83:21)"},"timestamp":1667905137554,"message":"The resource you are requesting could not be found","node":{"parameters":{"resource":"order","operation":"update","orderId":"={{ $node[\"WooCommerce\"].json[\"id\"] }}","updateFields":{},"billingUi":{},"couponLinesUi":{},"feeLinesUi":{},"lineItemsUi":{"lineItemsValues":[{"name":"={{ $json[\"itemData\"][\"Item\"] }}","productId":789,"variationId":0,"quantity":1,"taxClass":"","subtotal":"={{ $json[\"itemData\"][\"Value\"] }}","total":"={{ $json[\"itemData\"][\"Value\"] }}","metadataUi":{}}]},"metadataUi":{},"shippingUi":{},"shippingLinesUi":{}},"id":"99fe1978-e5d3-4dab-afcc-fe2e6743e564","name":"WooCommerce1","type":"n8n-nodes-base.wooCommerce","typeVersion":1,"position":[1080,500],"credentials":{"wooCommerceApi":{"id":"9","name":"Pink Tulip"}}},"httpCode":"404","description":"No route was found matching the URL and request method."}

Please share the workflow

Share the output returned by the last node

(This is what the Set node returned in the last failed attempt)

[
  {
    "status": "success",
    "response": {},
    "itemData": {
      "Modified Date": 1667901161469,
      "Created Date": 1667901161469,
      "Created By": "admin_user_bkt-carttest_live",
      "Client": "PT",
      "id": 27,
      "Form ID": 8,
      "Item": "blah",
      "Value": "0.91",
      "_id": "1667901161469x153075877227378140"
    },
    "body": {
      "card": "TEST ORDER",
      "cusFirst": "TEST",
      "cusLast": "ORDER",
      "cusBusiness": "TEST ORDER",
      "cusEmail": "[email protected]",
      "cusPhone": "0861 185 690",
      "recipientPhone": "0861 185 690",
      "delDate": "Wednesday 30 November 2022",
      "delNotes": "TEST ORDER",
      "recipientFirst": "TEST",
      "recipientLast": "ORDER",
      "recipientBusiness": "",
      "recipientAddress1": "142 Main Rd",
      "recipientAddress2": "",
      "recipientSuburb": "McLaren Vale",
      "recipientPostcode": "5171",
      "recipientCountry": "Australia",
      "delFeeName": "Aldinga",
      "delFeePrice": "9.09",
      "total": "15.45",
      "subID": "00011",
      "orderItems": "27,28,32",
      "payment": "Cash",
      "itemValue": "6.36",
      "unix": 1669766400
    }
  },
  {
    "status": "success",
    "response": {},
    "itemData": {
      "Modified Date": 1667901161469,
      "Created Date": 1667901161469,
      "Created By": "admin_user_bkt-carttest_live",
      "Client": "PT",
      "id": 28,
      "Form ID": 8,
      "Item": "something",
      "Value": "9.09",
      "_id": "1667901161469x709925705856672400"
    }
  },
  {
    "status": "success",
    "response": {},
    "itemData": {
      "Modified Date": 1667903606695,
      "Created Date": 1667903196185,
      "Created By": "non_authenticated_user_bkt-carttest_live",
      "Client": "PT",
      "id": 32,
      "Form ID": 8,
      "Item": "something",
      "Value": "0.91",
      "_id": "1667903196138x981760170724129000"
    }
  }
]

Information on your n8n setup

  • n8n version: 0.197.1
  • Database you’re using (default: SQLite): SQLite
  • Running n8n with the execution process [own(default), main]: default
  • Running n8n via [Docker, npm, n8n.cloud, desktop app]: Docker-compose (DigitalOcean)

Hi @bakkbone, from your description it’s not 100% clear to me which node exactly throws the error. However, seeing your logic is working fine for the first item, I suspect what’s happening here is this.

An expression such as {{ $node["WooCommerce"].json["id"] }} would for the first item arriving on its node look up the first item from the WooCommerce node. For the second item it would look up the second item from the WooCommerce node which fails.

So you probably want to always read the first (and only) order ID from your WooCommerce node using an expression such as {{ $("WooCommerce").first().json.id }} (this expression format is fairly new, so you might need to upgrade your n8n version for this to work).

Hope this helps!

1 Like

Nail has been hit squarely on the head there - thanks so much!

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.