@ecomplus/utils
Version:
JS utility functions to E-Com Plus (not only) related apps
25 lines • 1.36 kB
TypeScript
export default specValues;
/**
* @method
* @memberof ecomUtils
* @name specValues
* @description Returns array of spec objects for specified grid.
* @param {Object.<string, *>|Array} product - Product body or array of variation objects
* @param {string} gridId - Grid ID string such as 'color'
* @param {Array} [grids] - List of grid objects
* @returns {Array}
*
* @example
* const product = { 'name': 'Cruzeiro 2019', 'variations': [ { 'name': 'Cruzeiro 2019 / P / azul', 'specifications': { 'colors': [ { 'text': 'azul', 'value': '#3300ff' } ] } } ] }
* const gridId = 'colors'
* const grid1 = { 'grid_id': 'size', 'title': 'Tamanho', 'options': [ { 'text': 'P', 'option_id': 'pp' } ] }
* const grid2 = { 'title': 'Cores', 'grid_id': 'colors', 'options': [ { 'text': 'vermelho', 'option_id': 'vermelho', 'colors': [ '#ff0000' ] }, { 'text': 'azul', 'option_id': 'azul', 'colors': [ '#3300ff' ] } ] }
* const grid3 = { 'title': 'Conector', 'grid_id': 'conector', 'options': [ { 'text': 'USB', 'option_id': 'usb' } ] }
* const grids = [ grid1, grid2, grid3 ]
* ecomUtils.specValues(product, gridId, grids)
* // => [{text: "vermelho", value: "#ff0000"}, {text: "azul", value: "#3300ff"}]
*/
declare function specValues(product: {
[x: string]: any;
} | any[], gridId: string, grids?: any[]): any[];
//# sourceMappingURL=spec-values.d.ts.map