This article is also available in:
If you are a developer, and want to use our app for custom functionality, you can access these events:

tomitVariantChanged
Listen to this event to reparse data if you need to

tomitLoaded
for instance If you would like to get inventory information for multiple products, you can use our object once it's loaded:
document.addEventListener('tomitLoaded', function(e) {
var productIds = ['123422,464117'];
tomitProductInventoryInfo.getProductsInventoryInformation(productIds).then(function(e){
console.log(e);
});
});
</script>


tomitProductLoaded

For instance, on a product page if you would like to get the product object with inventory information, you can listen for the tomitProductLoaded event:

<script type="text/javascript">
document.addEventListener('tomitProductLoaded', function(e) {
console.log('product loaded');
console.log(tomitProductInventoryInfo.activeProduct);
});
</script>


If you would like to display the inventory block in another element on the page as well (sometimes you have a mobile template hidden for instance)

<script type="text/javascript">

document.addEventListener('tomitProductLoaded', function(e) {
if(tomitProductInventoryInfo.activeProduct.variants.hasOwnProperty(tomitProductInventoryInfo.selectedVariantId)){
document.getElementsByClassName('inventoryLocationInformation')[0].getElementsByClassName('inventoryLocationLoading')[0].remove();
document.getElementsByClassName('inventoryLocationInformation')[0].appendChild(tomitProductInventoryInfo.listInventory(tomitProductInventoryInfo.activeProduct.variants[tomitProductInventoryInfo.selectedVariantId].inventoryItem.locations, false));
}
});

</script>
Was this article helpful?
Cancel
Thank you!