WooCommerce Trigger Processing non paid customers too

WooCommerce Trigger fires the flow even for non paid customers. This is not a problem with n8n.

But I feel this can be solved with n8n IF node.

Like Checking the Customer is actually done the payment or not. Then Proceed Accordingly.

Any input on this? @jan @RicardoE105 @harshil1712

image

Guess makes sense, as the order got created. Depending on the payment-method it is probably even expected.

Do not have a WooCommerce-Account, so could sadly not test myself. Is the information, if the order got paid or not, sent with the Webhook? If not, is there currently a way to query that information with n8n? Because else we can then at least make that possible.

This is what Iā€™m getting in WooCommerce Trigger Node when payment is successful

Can I send the test site credentials?

[
   "-"{
      "id":248,
      "parent_id":0,
      "number":"248",
      "order_key":"wc_order_PNs0syx7E3A5R",
      "created_via":"checkout",
      "version":"4.7.0",
      "status":"processing",
      "currency":"INR",
      "date_created":"2020-11-25T14:06:27",
      "date_created_gmt":"2020-11-25T14:06:27",
      "date_modified":"2020-11-25T14:06:27",
      "date_modified_gmt":"2020-11-25T14:06:27",
      "discount_total":"1113.00",
      "discount_tax":"0.00",
      "shipping_total":"0.00",
      "shipping_tax":"0.00",
      "cart_tax":"0.00",
      "total":"0.00",
      "total_tax":"0.00",
      "prices_include_tax":false,
      "customer_id":2,
      "customer_ip_address":"103.197.35.206",
      "customer_user_agent":"Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.66 Safari/537.36",
      "customer_note":"",
      "-""billing":{
         "first_name":"MC",
         "last_name":"Naveen",
         "company":"",
         "address_1":"",
         "address_2":"",
         "city":"",
         "state":"",
         "postcode":"",
         "country":"",
         "email":"[email protected]",
         "phone":""
      },
      "-""shipping":{
         "first_name":"",
         "last_name":"",
         "company":"",
         "address_1":"",
         "address_2":"",
         "city":"",
         "state":"",
         "postcode":"",
         "country":""
      },
      "payment_method":"",
      "payment_method_title":"",
      "transaction_id":"",
      "date_paid":"2020-11-25T14:06:27",
      "date_paid_gmt":"2020-11-25T14:06:27",
      "date_completed":null,
      "date_completed_gmt":null,
      "cart_hash":"2b60240305b94fa412edf2d0e6053a98",
      "-""meta_data":[
         "-"{
            "id":3266,
            "key":"is_vat_exempt",
            "value":"no"
         },
         "-"{
            "id":3274,
            "key":"_woocs_order_rate",
            "value":"1"
         },
         "-"{
            "id":3275,
            "key":"_woocs_order_base_currency",
            "value":"INR"
         },
         "-"{
            "id":3276,
            "key":"_woocs_order_currency_changed_mannualy",
            "value":"0"
         }
      ],
      "-""line_items":[
         "-"{
            "id":91,
            "name":"License Key for 1 Year. [Single Site]",
            "product_id":207,
            "variation_id":0,
            "quantity":1,
            "tax_class":"",
            "subtotal":"1113.00",
            "subtotal_tax":"0.00",
            "total":"0.00",
            "total_tax":"0.00",
            "-""taxes":[
               
            ],
            "-""meta_data":[
               
            ],
            "sku":"",
            "price":0,
            "parent_name":null
         }
      ],
      "-""tax_lines":[
         
      ],
      "-""shipping_lines":[
         
      ],
      "-""fee_lines":[
         
      ],
      "-""coupon_lines":[
         "-"{
            "id":92,
            "code":"test",
            "discount":"1113",
            "discount_tax":"0",
            "-""meta_data":[
               "-"{
                  "id":594,
                  "key":"coupon_data",
                  "-""value":{
                     "id":246,
                     "code":"test",
                     "amount":"1500",
                     "-""date_created":{
                        "date":"2020-11-25 12:39:55.000000",
                        "timezone_type":1,
                        "timezone":"+00:00"
                     },
                     "-""date_modified":{
                        "date":"2020-11-25 12:44:47.000000",
                        "timezone_type":1,
                        "timezone":"+00:00"
                     },
                     "date_expires":null,
                     "discount_type":"fixed_cart",
                     "description":"",
                     "usage_count":1,
                     "individual_use":false,
                     "-""product_ids":[
                        
                     ],
                     "-""excluded_product_ids":[
                        
                     ],
                     "usage_limit":0,
                     "usage_limit_per_user":0,
                     "limit_usage_to_x_items":null,
                     "free_shipping":false,
                     "-""product_categories":[
                        
                     ],
                     "-""excluded_product_categories":[
                        
                     ],
                     "exclude_sale_items":false,
                     "minimum_amount":"",
                     "maximum_amount":"",
                     "-""email_restrictions":[
                        
                     ],
                     "virtual":false,
                     "-""meta_data":[
                        
                     ]
                  },
                  "display_key":"coupon_data",
                  "-""display_value":{
                     "id":246,
                     "code":"test",
                     "amount":"1500",
                     "-""date_created":{
                        "date":"2020-11-25 12:39:55.000000",
                        "timezone_type":1,
                        "timezone":"+00:00"
                     },
                     "-""date_modified":{
                        "date":"2020-11-25 12:44:47.000000",
                        "timezone_type":1,
                        "timezone":"+00:00"
                     },
                     "date_expires":null,
                     "discount_type":"fixed_cart",
                     "description":"",
                     "usage_count":1,
                     "individual_use":false,
                     "-""product_ids":[
                        
                     ],
                     "-""excluded_product_ids":[
                        
                     ],
                     "usage_limit":0,
                     "usage_limit_per_user":0,
                     "limit_usage_to_x_items":null,
                     "free_shipping":false,
                     "-""product_categories":[
                        
                     ],
                     "-""excluded_product_categories":[
                        
                     ],
                     "exclude_sale_items":false,
                     "minimum_amount":"",
                     "maximum_amount":"",
                     "-""email_restrictions":[
                        
                     ],
                     "virtual":false,
                     "-""meta_data":[
                        
                     ]
                  }
               }
            ]
         }
      ],
      "-""refunds":[
         
      ],
      "currency_symbol":"ā‚¹",
      "-""_links":{
         "-""self":[
            "-"{
               "href":"https://examplesite.com/wp-json/wc/v3/orders/248"
            }
         ],
         "-""collection":[
            "-"{
               "href":"https://examplesite.com/wp-json/wc/v3/orders"
            }
         ],
         "-""customer":[
            "-"{
               "href":"https://examplesite.com/wp-json/wc/v3/customers/2"
            }
         ]
      }
   }
]

Is the "status":"processing", which informs about the payment status? Because then it would be easily possible with the IF-Node as you proposed.

1 Like

@jan I found something interesting.

If the Payment is failed the status will be pending.
If the Payment is successful, the status will change to processing

Adding if node right after the WooCommerce Trigger will solve the issue. I guess.

Let me check it

1 Like

Yes. It solved the issue. Keep connecting your flows from True Branch.

Example Workflow:

{
  "nodes": [
    {
      "parameters": {
        "event": "order.created"
      },
      "name": "WooCommerce Trigger",
      "type": "n8n-nodes-base.wooCommerceTrigger",
      "typeVersion": 1,
      "position": [
        750,
        330
      ],
      "webhookId": "a6781718-8f00-4c4c-abbb-42e5aa54f7f1",
      "credentials": {
        "wooCommerceApi": "Store WooCommerece"
      }
    },
    {
      "parameters": {
        "conditions": {
          "string": [
            {
              "value1": "={{$node[\"WooCommerce Trigger\"].json[\"status\"]}}",
              "value2": "processing"
            }
          ]
        }
      },
      "name": "IF",
      "type": "n8n-nodes-base.if",
      "typeVersion": 1,
      "position": [
        930,
        330
      ]
    }
  ],
  "connections": {
    "WooCommerce Trigger": {
      "main": [
        [
          {
            "node": "IF",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}
1 Like

Glad to hear that it worked. Have fun!

1 Like