Using Data Formatters to operate with Webhook data
Adrián Brito
Hello, I’m facing a big issue and I hope someone can help me out.
When an order is fulfilled in any of our stores, we automatically send a WhatsApp message to the customer. Since we operate with Cash on Delivery (COD), we need to inform the customer of the exact amount they need to pay upon delivery.
The issue arises when an order contains 2 or more products. In these cases, we automatically apply a discount (for example, offers like BOGO or 50% off the 2nd unit), but we can’t retrieve the final amount correctly with Botsailor.
For instance, let’s say a customer places an order for 2 units of a product for 39.99€. If they had purchased only 1 unit, it would cost 29.99€, so there’s a 20€ discount on the second unit. We need to inform the customer that they owe 39.99€, but in the Webhook Response Mapping, we can only access the value 29.99€.
We thought we could solve this using Data Formatters. The logic we want to implement is straightforward:
TOTAL = 29.99€ + 29.99€ - 20€ = 39.99€
We’d like to calculate the final amount using formatters, but I haven’t been able to make it work.
Can anyone help me out with this, please?
Thanks in advance, and I hope I explained the issue clearly.
When an order is fulfilled in any of our stores, we automatically send a WhatsApp message to the customer. Since we operate with Cash on Delivery (COD), we need to inform the customer of the exact amount they need to pay upon delivery.
The issue arises when an order contains 2 or more products. In these cases, we automatically apply a discount (for example, offers like BOGO or 50% off the 2nd unit), but we can’t retrieve the final amount correctly with Botsailor.
For instance, let’s say a customer places an order for 2 units of a product for 39.99€. If they had purchased only 1 unit, it would cost 29.99€, so there’s a 20€ discount on the second unit. We need to inform the customer that they owe 39.99€, but in the Webhook Response Mapping, we can only access the value 29.99€.
We thought we could solve this using Data Formatters. The logic we want to implement is straightforward:
TOTAL = 29.99€ + 29.99€ - 20€ = 39.99€
We’d like to calculate the final amount using formatters, but I haven’t been able to make it work.
Can anyone help me out with this, please?
Thanks in advance, and I hope I explained the issue clearly.