import { IkasLanguageOption, IkasLocaleOption, IkasProduct, IkasThemePageType } from "../../../storefront-models/src"; import { BaseStore } from "../../../stores/base"; /** * Initializes the base store by setting the current page type. * * @ai-category BaseStore, Store * * @param pageType - The page type to assign as the current page type in the base store. * @returns void * * @example * ```typescript * import { initBaseStore } from "@ikas/bp-storefront"; * import { IkasThemePageType } from "@ikas/bp-storefront"; * * initBaseStore(IkasThemePageType.PRODUCT_DETAIL); * ``` */ export declare function initBaseStore(pageType: IkasThemePageType): void; /** * Switches the storefront to the routing associated with `localeOption` and redirects the browser * to the equivalent URL under that routing. * * Reads the routing directly from `localeOption.routing`, then performs a full-page redirect via * `window.location.replace`. For CATEGORY/BRAND/PRODUCT pages, the localized slug from the page's * metadata translations is used when available; otherwise the visitor stays on the current path * (with the current routing prefix swapped for the new one). Query string and hash are preserved. * * @ai-category BaseStore, Store * * @param baseStore - The base store instance (used to read the current page type for slug * resolution on detail pages). * @param localeOption - The locale option the visitor selected. Render `baseStore.localeOptions` * as a list (e.g. a country/region picker) and pass the chosen entry directly to this function. * @returns void. * * @example * ```tsx * import { setLocalization, baseStore } from "@ikas/bp-storefront"; * * function LocalizationSwitcher() { * return ( * * ); * } * ``` */ export declare function setLocalization(baseStore: BaseStore, localeOption: IkasLocaleOption): void; /** * Switches the storefront to the routing identified by `language` and redirects the browser to * the equivalent URL under that routing. * * Looks up the routing by `language.id`, then performs a full-page redirect via * `window.location.replace`. For CATEGORY/BRAND/PRODUCT pages, the localized slug from the * page's metadata translations is used when available; otherwise the visitor stays on the * current path (with the current routing prefix swapped for the new one). Query string and * hash are preserved. * * @ai-category BaseStore, Store * * @param baseStore - The base store instance (used to read the current page type for slug * resolution on detail pages). * @param language - The language option the visitor selected. Render `baseStore.languageOptions` * as a list (e.g. a dropdown) and pass the chosen entry directly to this function. * @returns void. No-op if no routing matches `language.id`. * * @example * ```tsx * import { setLanguage, baseStore } from "@ikas/bp-storefront"; * * function LanguageSwitcher() { * return ( * * ); * } * ``` */ export declare function setLanguage(baseStore: BaseStore, language: IkasLanguageOption): void; /** * Fetches a single product by id and returns it as a full `IkasProduct`. * * Use this when a lightweight reference (e.g. a cart line's `IkasOrderLineVariant`, which carries * neither `salesChannels` nor `stock`) needs product-level data: the returned product includes * `salesChannels` filtered to the active sales channel (with `minQuantityPerCart` / * `maxQuantityPerCart`) and per-variant `stock` (summed over the sales channel's configured * stock locations). `selectedVariantValues` is seeded from the first active variant (or the * first variant when none is active). For multiple ids, prefer `bs_searchProductsById` — one * batched request. * * @ai-category Product, Search * @ai-related bs_searchProductsById * * @param baseStore - The base store instance * @param params - `{ productId }` — id of the product to fetch * @returns `{ isSuccess, product }` — `product` is null when not found or on failure * * @example * ```tsx * import { baseStore, bs_searchProductById, IkasStorefrontConfig } from "@ikas/bp-storefront"; * * const { isSuccess, product } = await bs_searchProductById(baseStore, { productId }); * if (isSuccess && product) { * const channel = product.salesChannels?.find(sc => sc.id === IkasStorefrontConfig.salesChannelId); * console.log(channel?.maxQuantityPerCart); * } * ``` */ export declare function bs_searchProductById(baseStore: BaseStore, params: { productId: string; }): Promise<{ isSuccess: boolean; product: IkasProduct | null; }>; /** * Batch-fetches products by id in a single request and returns them as full `IkasProduct` objects. * * The go-to function when cart lines (or any lightweight reference) need product-level data they * do not carry: `IkasOrderLineVariant` has neither `salesChannels` nor `stock`, while the products * returned here include `salesChannels` filtered to the active sales channel (with * `minQuantityPerCart` / `maxQuantityPerCart`) and per-variant `stock` (summed over the sales * channel's configured stock locations). Collect the distinct `productId`s of the lines and * fetch them in ONE call instead of one request per line. Called with an empty `productIds`, * it returns `{ isSuccess: true, products: [] }` without a network request. * * @ai-category Product, Cart, Search * @ai-related bs_searchProductById, changeItemQuantity * * @param baseStore - The base store instance * @param params - `{ productIds }` — product ids to fetch (deduplicate before calling) * @returns `{ isSuccess, products }` — `products` is null on failure * * @example * ```tsx * import { baseStore, bs_searchProductsById, cartStore, IkasStorefrontConfig } from "@ikas/bp-storefront"; * * // Enforce per-cart quantity limits on cart lines: * const productIds = [ * ...new Set( * (cartStore.cart?.orderLineItems ?? []) * .map(item => item.variant.productId) * .filter((id): id is string => !!id) * ), * ]; * const { products } = await bs_searchProductsById(baseStore, { productIds }); * const maxByProductId = new Map(); * for (const p of products ?? []) { * const channel = p.salesChannels?.find(sc => sc.id === IkasStorefrontConfig.salesChannelId); * maxByProductId.set(p.id, channel?.maxQuantityPerCart ?? null); * } * ``` */ export declare function bs_searchProductsById(baseStore: BaseStore, params: { productIds: string[]; }): Promise<{ isSuccess: boolean; products: IkasProduct[] | null; }>;