The MySizeID event listener allows the user to receive a notification whenever a size
recommendation as being reported to the system.
setMySizeSizeRecommenderListener((recommendedSize)->())
This function accepts a function that receives the recommended size as a callback.
Here are examples of how this event can be used:
1. Auto select the size on the item page based on the size recommended received in the
MySizeID widget. Here is an example of how this event can be registered:
setMySizeSizeRecommendedListener(x =>
{
if (x === null) return;
const element = document.querySelector(`.size-${x}`);
if (element === null) return;
element.click();
});
IMPORTANT: In the example above, we assume that the name of the class that we are willing
to click looks something like size-XL. It’s true for the purpose of this example only. You will need
to write the code that will locate the correct element on your page).
2. Change the text of the widget to show “NOT IN STOCK” when there’s no size available for
the user
setMySizeSizeRecommendedListener(x=>{
if (x===null) return;
if (isInStock(x)) return;
setMySizeCTAText("NOT IN STOCK")
});
IMPORTANT: The function isInStock needs to be developed on your end
Comments
0 comments
Please sign in to leave a comment.