Skip to main content
All CollectionsVolume Discounts
Custom Javascript & Discount Data
Custom Javascript & Discount Data

Use custom javascript to do things with our discount data that is returned from our API.

Steven avatar
Written by Steven
Updated over 2 years ago

Run Custom JS after discounts are calculated

Use the "Custom Javascript (Settings Override)" section in the advanced settings of our app to add code that runs automatically after our API returns the discount data. You can add as many handlers as you want in the "window.appikonDiscount.postDiscountHandlers" global array object. Each function called in that list is passed an object that contains all of the discount information, which is documented below.

window.appikonDiscount.postDiscountHandlers = [];
window.appikonDiscount.postDiscountHandlers.push(
(data) => {
console.log(data);
}
);

Post Discount Handler Data

This is just some of the data available to you in this object. You can use the example above log it in the console and view the whole object.

{
discounts = {
discounted_price_html [formatted final discounted price],
discounted_price [final discounted price],
cart = {
items = [
{
product_id,
quantity,
discounted_price_html [formatted line item discounted price],
discounted_price [line item discounted price]
},
......
]
}
}
}
Did this answer your question?