@shopgate/engage
Version:
Shopgate's ENGAGE library.
7 lines • 756 B
JavaScript
/**
* Check if product inventory is orderable.
* @param {Object} location The location to check.
* @param {Object} inventory The location inventory to check.
* @returns {boolean}
*/export function isProductAvailable(){var location=arguments.length>0&&arguments[0]!==undefined?arguments[0]:{};var inventory=arguments.length>1&&arguments[1]!==undefined?arguments[1]:{};var _ref=location||{},isComingSoon=_ref.isComingSoon;var _ref2=inventory||{},_ref2$isAvailable=_ref2.isAvailable,isAvailable=_ref2$isAvailable===void 0?false:_ref2$isAvailable,_ref2$visible=_ref2.visible,visible=_ref2$visible===void 0?0:_ref2$visible;if(isComingSoon){return false;}if(isAvailable===false){return false;}if(visible===null){// Blind mode
return true;}return visible>0;}