Integration VIA Scripts
Initialize the following code snippet before closing <body> tag at each page of your website:
...
<script>
var widgetScript = document.createElement('script');
widgetScript.onload = function () {
_garderoboWidget.then(function(widget) {
widget.init('<API_KEY>', {lang_code: 'en', user_id: '<user_id>'});
});
};
widgetScript.src = 'https://widget.garderobo.ai/widget.js';
document.head.appendChild(widgetScript);
</script>
</body>You also need to initialize a set of items that have already been added to the shopping cart
_garderoboWidget.then(function(widget) {
//Get a list of all identifiers of items added to the cart
var cartProductsArray = [...]
//The second parameter should be passed the relative path to the cart page
widget.setCartProducts(cartProductsArray, '/cart/');
});To initialize the favorite products, the following script must be executed
Callback Functions
Event "Add item to cart"
When a user clicks on the "Add to Cart" button in the widget, you need to handle this signal and perform the add to cart action on the site.
Event "Add product to favorites"
When a user clicks on the "Favorites" icon, you need to process the following signal and add the product to the site's favorites or remove it from the favorites.
Full Code
The complete widget initialization script should look like this:
Last updated