This guide explains how to send Ravelin data about discounts.
On this page:It is common for merchants to offer different types of discounts in relation to the products they sell. This guide is intended to help explain how best to send this information to Ravelin.
Regardless of how you implement discounts, the guiding principle here should be that the order price sent to Ravelin must always match what the customer spent on the order.
There are two different ways you can share discount data with Ravelin. The main difference depends on whether you have access to the price of an item before a discount was applied.
If the price of the item before a discount was applied is known, send the item price without any discount applied. This is the preferred way to send discount data to Ravelin.
Represent the discount as an extra item in the order, with a negative item price. Do not include the item sku field on items representing discounts.
This approach can also be used for general promotions (e.g. 10% off the whole order).
If there are multiple items in the order which have a discount applied, sum all the discounts and set that as the discount item price.
For example, if a customer is buying two pizzas priced £10 and £15, and the first pizza has a £2 discount and the second pizza has a £3 discount, for a total discount of £5, the order object should be represented as follows:
{
"orderId": "abcde12345-ZXY",
"creationTime": 1512828988826,
"price": 2000,
"currency": "GBP",
"items": [
{
"sku": "0001",
"name": "Margherita Pizza",
"quantity": 1,
"price": 1000
},
{
"sku": "0002",
"name": "Pepperoni Pizza",
"quantity": 1,
"price": 1500
},
{
"name": "Total Discount",
"quantity": 1,
"price": -500
}
]
}
The order object should be included as part of a full request, for example a Checkout request.
If you would prefer to see an individual item for each discount do not sum all the discounts but instead create a separate item for each discount. You can use the item name field to describe the individual discounts.
For example, in this case, the order object should be represented as follows:
{
"orderId": "abcde12345-ZXY",
"creationTime": 1512828988826,
"price": 2000,
"currency": "GBP",
"items": [
{
"sku": "0001",
"name": "Margherita Pizza",
"quantity": 1,
"price": 1000
},
{
"name": "Margherita Pizza Discount",
"quantity": 1,
"price": -200
},
{
"sku": "0002",
"name": "Pepperoni Pizza",
"quantity": 1,
"price": 1500
},
{
"name": "Pepperoni Pizza Discount",
"quantity": 1,
"price": -300
}
]
}
If the price of the item before the discount was applied is not known, send the item price with the discount applied.
The impact of sending discounts in this way is that you will not be able to visualise the use of discounts when viewing orders in Ravelin, or target any related behaviour.
An example order object for this option is shown below:
{
"orderId": "abcde12345-ZXY",
"creationTime": 1512828988826,
"price": 2000,
"currency": "GBP",
"items": [
{
"sku": "0001",
"name": "Margherita Pizza",
"quantity": 1,
"price": 800
},
{
"sku": "0002",
"name": "Pepperoni Pizza",
"quantity": 1,
"price": 1200
}
]
}
There are some other things to keep in mind when sending discount related data.
sku
and name
.An example of an order containing both a discount and a free item is shown below:
{
"orderId": "abcde12345-ZXY",
"creationTime": 1512828988826,
"price": 800,
"currency": "GBP",
"items": [
{
"sku": "0001",
"name": "Margherita Pizza",
"quantity": 2,
"price": 1000
},
{
"name": "Total Discount",
"quantity": 1,
"price": -200
},
{
"sku": "0009",
"name": "Free promotional item",
"quantity": 1,
"price": 0
}
]
}
Was this page helpful?