Overview
The Fondue Cashback SDK allows you to easily integrate cashback functionality into your e-commerce platform. This SDK exposes methods on the window.Fondue
object for handling notes and item addition events.
To integrate the Fondue Cashback SDK, include the following script in the <head>
section of your HTML:
<body>
<script
async
id="fondue-cashback"
src="<https://public.getfondue.com/cashback-extension/cart/fundle.js>"
type="application/javascript"
shop="[YOUR_SHOP]"
api="[AJAX / STOREFRONT]">
</script>
</body>
Replace [YOUR_SHOP]
with your shop's unique identifier. (for example: amazing-shop.myshopify.com
Replace [AJAX / STOREFRONT]
with your current api you are using in shopify
i.e: api=AJAX
if you are using the common cart.js
api or api=STOREFRONT
if you are using shopify storefront api
Our JS SDK will have window.Fondue.status
set to “ready” when it is ready for use and available to use. Please check this prior to calling any SDK functions.
Our JS SDK needs to know when a product is added or removed from cart. You will need to call window.Fondue.cart.dispatchUpdatedCartEvent()
any time the contents of the cart is updated. This will cause the Fondue SDK to fetch the cart contents and make any required updates to the cashback available to the customer.
Example:
//in-case this
function addItemToCart(id) {
... your implemention
if (window.Fondue.status === "ready") {
window.Fondue.cart.dispatchUpdatedCartEvent**()**
}
}
In order to fetch the cart contents we will need to know the ID for the cart of the current customer.