UNPKG

@selldone/sdk-storefront

Version:

A TypeScript SDK to connect to your shop and build a fully functional storefront and website by simply developing a frontend web application. All backend operations are seamlessly managed by the serverless Selldone solution.

42 lines 1.87 kB
/* * Copyright (c) 2023-2024. Selldone® Business OS™ * * Author: M.Pajuhaan * Web: https://selldone.com * ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ * * All rights reserved. In the weave of time, where traditions and innovations intermingle, this content was crafted. * From the essence of thought, through the corridors of creativity, each word, and sentiment has been molded. * Not just to exist, but to inspire. Like an artist's stroke or a sculptor's chisel, every nuance is deliberate. * Our journey is not just about reaching a destination, but about creating a masterpiece. * Tread carefully, for you're treading on dreams. */ /** * Language of returned article determine by 'X-Localization' in the header. * * @param product_id * @param options */ export default function XapiProductGet(product_id, options) { product_id = parseInt("" + product_id); const url = window.XAPI.GET_PRODUCT_INFO(this.shop_name, product_id); return this.getNow(url, options, (caches) => { // Find product in previously fetched products list: let foundProduct = null; // @ts-ignore for (const [cacheKey, cacheValue] of caches.entries()) { const products = cacheValue?.products || null || undefined; if (Array.isArray(products)) { const found = products.find((p) => p.id === product_id); if (found) { // console.log('WE FIND!', product_id, found); foundProduct = found; break; // Exit the loop once the product is found } } } if (foundProduct) return { product: foundProduct }; }); } //# sourceMappingURL=XapiProductGet.js.map