UNPKG

@ecomplus/utils

Version:

JS utility functions to E-Com Plus (not only) related apps

33 lines 956 B
export default inStock; /** * @method * @memberof ecomUtils * @name inStock * @description Check if item has stock equal or greater than minimum quantity. * @param {Object.<string, *>} product - Body object (product or variation) * @returns {boolean} * * @example * // Full object ref.: https://developers.e-com.plus/docs/api/#/store/products/ * const product = { sku: 'TEST', name: 'Test', price: 10 } * ecomUtils.inStock(product) * // => true * product.quantity = 5 * ecomUtils.inStock(product) * // => true * product.min_quantity = 10 * ecomUtils.inStock(product) * // => false * ecomUtils.inStock({ quantity: 1, min_quantity: 2 }) * // => false * ecomUtils.inStock({ quantity: 0 }) * // => false * ecomUtils.inStock({ quantity: 1, min_quantity: 1 }) * // => true * ecomUtils.inStock({ quantity: 1 }) * // => true */ declare function inStock(product: { [x: string]: any; }): boolean; //# sourceMappingURL=in-stock.d.ts.map