Custom Implantation Events
Introduction
Available events
Usage
// your-store_prescript.js
const prescript = {
/* Omitted for brevity */
};
const events = {
onRecommendation: (recObject) => {
let myRecommendationEl = document.createElement("div");
const myRecomendationSelector = "my-cool-class";
const myRecommendationTemplate = `<span>Hi there! I'm recommending ${recObject.recommendedSize} to ${recObject.profileName} :)</span>`;
myRecommendationEl.className = myRecommendationSelector;
myRecommendationEl.innerHTML = myRecommendationTemplate;
document.body.appendChild(myRecommendationEl);
},
onAddToCart: (cartPayload) => {
myStore.addProductToCart({
quant: cartPayload.quantity,
size: cartPayload.size,
});
},
onProductFound: (product) => {
console.log("Found a product!", product)
},
onProductNotFound: () => {
console.log(
"Hello, Sirrah! alas, the product is yet to be found. what a pity! but at least that throwing error is not around anymore."
);
},
};
// Executing Sizebay services
window.Sizebay.Implantation(prescript, events);
Last updated