import { IFilledDimensionUnits } from '../../../Interfaces/Declination'; import IIndexedProduct from '../../../Interfaces/Indexed/Product'; import ITranslation from '../../../Interfaces/Translation'; import IAttribute, { IAttributeValue } from '../../../Interfaces/Attribute'; import ICart, { ICartItem, ICartItemWithSubItem, IIndexedDeclination } from '../../../Interfaces/Cart'; import IAddress from '../../../Interfaces/Address'; import IStore from '../../../Interfaces/Store'; import { ICustomPriceItem } from '../../../Interfaces/G2'; import { IProductRecommendation } from '../../../Interfaces/Product'; import IInventoryItem from '../../../Interfaces/Product/IInventoryItem'; import ICustomer from '../../../Interfaces/Customer'; import IDiscountRule from '../../../Interfaces/Rules/IDiscountRule'; import ILang from '../../../utils/string'; import { IConcreteOrder, IGrassProduct, IVracType } from '../interfaces/products'; import { TExpeditionMethod, TFeesAppliedResponse } from '../interfaces/cart'; /** * @description Returns sell unit label in correct language for a specific product's other_units * @param {IFilledDimensionUnits[] | undefined} otherUnits The unit array we have to check to get the sell unit * @param {string | undefined} locale The language in which we want to return the label * @param {string[]} returnUnitForSlugs An array of the slugs we want to return the unit label for * @param {boolean} options.returnPlural If plural version should be returned * @param {boolean} options.returnShortByDefault If short version should be prioritized */ export declare const getProductSellUnitLabel: (otherUnits: IFilledDimensionUnits[] | undefined, locale?: string | undefined, returnUnitForSlugs?: string[], options?: { returnPlural?: boolean; returnShortByDefault?: boolean; }) => string; /** * @description Returns unit label in correct language for a specific product's other_units * @param {IFilledDimensionUnits[] | undefined} otherUnits The unit array we have to check to get the sell unit * @param {string} type The unit type to check * @param {string | undefined} locale The language in which we want to return the label * @param {string[]} returnUnitForSlugs An array of the slugs we want to return the unit label for * @param {boolean} options.returnPlural If plural version should be returned * @param {boolean} options.returnShortByDefault If short version should be prioritized */ export declare const getProductUnitLabel: (otherUnits: IFilledDimensionUnits[] | undefined, type: 'sale_unit' | 'inventory_unit', locale?: string | undefined, returnUnitForSlugs?: string[], options?: { returnPlural?: boolean; returnShortByDefault?: boolean; }) => string; /** * Returns the unit label for a specific slug * @param {string} unitSlug The slug of the unit for which we want to get the label * @param {string | undefined} locale The language in which we want to get the label * @param {boolean} getPluralVersion Optionnal - If the plural version should be returned instead. * @param {string[]} returnUnitForSlugs The slugs for which we want to return a default value, in this case the unit slug for unit * @param {boolean} returnShortByDefault Optionnal - If the short version should be prioritized */ export declare const getUnitLabelWithSlug: (unitSlug: string, locale?: string | undefined, getPluralVersion?: boolean, returnUnitForSlugs?: string[], returnShortByDefault?: boolean) => string; /** * Returns the plural unit label for a specific slug * @deprecated Should use getUnitLabelWithSlug instead (with props getPluralVersion=true) * @param {string} unitSlug The slug of the unit for which we want to get the label * @param {string | undefined} locale The language in which we want to get the label * @param {string[]} returnUnitForSlugs The slugs for which we want to return a default value, in this case the unit slug for unit */ export declare const getPluralUnitLabelWithSlug: (unitSlug: string, locale?: string | undefined, returnUnitForSlugs?: string[], useShortIfDifferent?: boolean) => string; export declare const getCorrectPluralSellUnit: (sellUnit: { unit?: ILang; value: number; }, locale?: string) => string; export declare const productUnitSupportsDecimals: (unitSlug: string, isService?: boolean) => boolean; export declare const getProductAttributes: (product: IIndexedProduct) => { colors: string[]; dimensions: string[]; formats: string[]; }; export declare const getDescriptionLength: (description: ITranslation[], locale?: string) => number; export declare const getDescriptionString: (showFullDesc: boolean, maxLength: number, description: ITranslation[], locale?: string) => string; /** * Returns rounded product sell_unit quantities depending on current value, value of secondary input if existant and sale unit per command step ratio found in product. * @param value {number} - Current quantity as entered by user in first input * @param otherUnits {IFilledDimensionUnits[] | undefined} - FilledDimensionUnits found in product (possibly undefined) * @param value2 {number | undefined} - Current quantity as entered by user in second input (possibly undefined) * @param targetIsSecondaryInput {boolean} - If action was triggered from secondary input (defaults to false) */ export declare const getRoundedSellUnitProductQuantities: (value: number, otherUnits: IFilledDimensionUnits[] | undefined, value2: number | undefined, targetIsSecondaryInput?: boolean) => { qte1: number; qte2?: number | undefined; }; /** * Returns rounded product quantities depending on current value per command step ratio found in product. * @param value {number} - Current quantity as entered by user in first input * @param otherUnits {IFilledDimensionUnits[] | undefined} - FilledDimensionUnits found in product (possibly undefined) * @param type {'sale_unit' | 'inventory_unit'} - Quantity type for computing */ export declare const getRoundedUnitProductQuantities: (value: number, otherUnits: IFilledDimensionUnits[] | undefined, type: 'sale_unit' | 'inventory_unit') => number; /** * * @param {string} stringToSplit * @param {string} dummyStringToReplace.currentValue, optionnal, default : '%%-%%'. Used to provide general replace values for a specific string. Is applied to both sections of the splitted string. * @param {string} dummyStringToReplace.newValue, optionnal, default : ' - '. Used to provide general replace values for a specific string. Is applied to both sections of the splitted string. * @returns {string[]} */ export declare const splitOnDashes: (stringToSplit: string, dummyStringToReplace?: { currentValue: string; newValue: string; }) => string[]; /** * Get product name as array. Array created mostly by splitting name on dash symbol (and variations). * @param {IIndexedVariationAlgolia | IIndexedProduct} product * @param {string | undefined} locale * @returns {string[]} - Position 0 is the "commum section" of the name, and position 1 should contain all specifics (ex. color, size, etc...) */ export declare const getProdName: (product: any, locale: string | undefined, platform?: 'web' | 'pos', attributes?: IAttribute[]) => string[]; /** * Function getParentProductCategoryGroup * @param prod - Product to check */ export declare const getParentProductCategoryGroup: (prod: IIndexedProduct) => 'gazon' | 'beton' | 'vrac' | 'other'; /** * Function getProductFormOptions - Returns all AttributeValues for product to construct options in add to cart form * @param product - Product to check * @param attributes - Array of IAttributes to fetch info from */ export declare const getProductFormOptions: (product: IIndexedProduct, attributes: IAttribute[]) => { allColors: IAttributeValue[]; allDimensions: IAttributeValue[]; allFormats: IAttributeValue[]; }; /** * @description Checks if product is of type by checking TYPE attribute value. Works with indexed product or cart item. * @param product * @param type * @param excludeUndefined If excludeUndefined is true, products without the "type" attribute will return true * @returns boolean */ export declare const checkIfProductIsOfType: (product: Partial, type: string, excludeUndefined?: boolean) => boolean; /** * Check if provided sku/slug corresponds to a non-speciality grass item * @param sku Grass item's sku * @param slug Grass item's parent product slug * @param onlyBaseGrass Optionnal. If provided data should only be compared to base grass (aka Kentucky) */ export declare const checkIfIsNonSpecialityGrass: (sku: string, slug: string, onlyBaseGrass?: boolean) => boolean; export declare const checkIfProductIsInstallation: (item: IIndexedDeclination) => boolean; /** * Returns array of installation items found in provided array * @param items - Array of cart items or IIndexedDeclinations to check */ export declare const getAllInstallFromItems: (items: (ICartItem | IIndexedDeclination)[]) => (ICartItem | IIndexedDeclination)[]; /** * Function fuseGrassProducts * @description - Returns items with only one apparent grass product (used for detail customers). * ** FOR DISPLAY PURPOSES ONLY - Always save grass products separatly in ICart ** * @param recursiveItems - ICartItems with subitems (object created for display purposes) */ export declare const fuseGrassProducts: (recursiveItems: ICartItemWithSubItem[], isPro?: boolean) => ICartItemWithSubItem[]; export declare const isMinQtyFee: (slug: string) => boolean; export declare const getAllMinGrassQuantities: (grassProduct: IGrassProduct, isPro: boolean) => { pickup: number; shipping: number; install: number; }; export declare const getMinQtyFeeText: (parent_slug: string | undefined, grassProduct: IGrassProduct, isPro: boolean, locale?: string, expeditionMethod?: string, shortVersion?: boolean) => string; export declare const getMinQtyFeeAmountText: (parent_slug: string | undefined, locale: string | undefined, servicesFees: ICartItem[], showMinFeeAmount?: boolean) => string; export declare const getGrassQteText: (chosenDeclination: IIndexedDeclination | undefined, locale?: string) => string; export declare const getGrassServicesFees: (grassProduct: IGrassProduct, isPro: boolean, useFees: boolean, expeditionMethod: TExpeditionMethod, fetchProduct: (slug: string, locale: string | undefined, useFeeArray?: boolean, noDrafts?: boolean) => Promise, getIfAddressIsInsideZones: (address: IAddress | string) => Promise, getDistanceFromAddress: (start: IAddress | string, finish: IAddress | string) => Promise, locale: string, allStores: IStore[], chosenGrass: ICartItem, baseGrass?: ICartItem, customPriceList?: ICustomPriceItem[]) => Promise; export declare const getGrassSubQuestionsByType: (type: 'install' | 'pro') => import("../interfaces/products").IGrassSubQuestion[]; /** * @description For grass products. Over 1480pi2, if installation, quantities are rounded to rolls (10pi2) if pickup, and to half pal. if shipping * @param grassProduct * @param cartData * @returns quantity rounded to rolls with items to change or undefined */ export declare const handleGrassProductQtyRoundForShipping: (cartData: ICart, grassProduct: IGrassProduct | undefined) => { rounded: number; itemsToChange: { sku: string; qte: number; }[]; } | undefined; /** * Function roundGrassQte * @description Returns rounded grass quantity depending on current qty, if customer selected installation and pallet unit (if defined) * @param currentQte {number} - Current quantity as entered by user in input * @param isShipping {boolean} - Whether customer has selected installation option * @param palUnit {IFilledDimensionUnits | undefined} - Pallet FilledDimensionUnit (possibly undefined) */ export declare const roundGrassQte: (currentQte: number, isShipping: boolean, palUnit: IFilledDimensionUnits | undefined) => number; /** * Detects if customer has "Installation tout inclus". * @param customPriceList - Customer custom price list * @return All inclusive installation if exists, undefined otherwise */ export declare const getInstallationAllInclusiveFromPriceList: (customPriceList: ICustomPriceItem[] | undefined) => ICustomPriceItem | undefined; /** * Checks if all-inclusive installation is active. * @param hasInstallation - Whether the cart/form contains an installation * @param isPro - Whether the customer is a pro * @param customPriceList - Customer custom price list * @returns true if all-inclusive installation is active */ export declare const isInstallAllInclusiveActive: (hasInstallation: boolean, isPro: boolean, customPriceList: ICustomPriceItem[] | undefined) => boolean; /** * Force )$ to kentucky base grass and sod delivery fee if install all-inclusive. * @param item - The cart item to potentially override * @returns The item with zeroed price if applicable, or the original item */ export declare const applyAllInclusiveOverrides: (item: ICartItem) => ICartItem; export declare const shouldHideItemInCheckout: (item: ICartItem, allItems: ICartItem[]) => boolean; export declare const matchesFuelSurchargeParent: (surchargeSku: string, item: ICartItem) => boolean; export declare const getInstallationArray: (qte: number, baseGrassUpsells: IProductRecommendation[] | undefined, fetchProduct: (slug: string, locale: string | undefined, useFeeArray?: boolean, noDrafts?: boolean) => Promise, locale: string | undefined, isPro: boolean, chosenSku: string, customPriceList?: ICustomPriceItem[], returnOtherFees?: { engrais?: boolean; roulage?: boolean; }) => Promise; export declare const getInstallItemPrice: (parentSlug: string, servicesFees: ICartItem[]) => number | undefined; export declare const getConcreteQteText: (declination: IIndexedDeclination, locale?: string) => string; /** * @description returns all items in cart where attribute AVAILABILITY contains wanted type. * @param cartData * @param availabilityType */ export declare const getConcreteItemsByAvailability: (cartData: ICart, availabilityType: 'en-stock' | 'epuisement-stocks' | 'delais-a-prevoir' | 'aucune-production-prevue', returnTrueIfUndefined?: boolean) => ICartItem[]; /** * Function getVracType - constructs vrac helper object is cart contains vrac or vrac associated items. * @param stores * @param cartData * @param getInventoryItemCallback * @param inventoryItemArray * @returns IVracType object containing vrac_type enum value and vrac_store_ids where vrac items are available */ export declare const getVracType: (stores: IStore[], cartData: ICart, getInventoryItemCallback: (sku: string) => Promise, inventoyItemArray?: IInventoryItem[]) => Promise; /** * Get all possible fees for a cart with basic info, to show approx. fee total before all data is saved in cart * * @param useFees If local fee array should be used, to save database calls * @param newCart Current cart data * @param deliveryType If fees should be checked for a pick-up or shipping order * @param fetchProduct Callback function for product fetch * @param getIfAddressIsInsideZones Callback function for zone check * @param getDistanceFromAddress Callback function to check distance with provided address * @param locale User's locale (fr or en) * @param allStores Full store array for space * @param isPro If customer associated with cart is a pro customer * @param grassProduct Constructed grass product from cart (with extra data for checks) * @param concreteOrder Constructed concrete products from cart (with extra data for checks) * @param settings.addOnePalletToPickup Optionnal - If additionnal pal. should be added for order * @param settings.saveToShippingPayload Optional - If data collected should be saved to cart's shipping_payload * @param settings.useStoreAddress Optionnal - Provided store ID for which the address should be used for check * @param settings.useDeliveryAddress Optionnal - If current carts shipping address should be used for check * @param settings.useAvailableVracStores Optionnal - Provided array of store IDs available for vrac order * @param customPriceList Optionnal - If pro customer with G2 custom price list and custom prices should be checked */ export declare const fetchFeesBeforeCart: (useFees: boolean, newCart: ICart, deliveryType: TExpeditionMethod, fetchProduct: (slug: string, locale: string | undefined, useFeeArray?: boolean, noDrafts?: boolean) => Promise, getIfAddressIsInsideZones: (address: IAddress | string) => Promise, getDistanceFromAddress: (start: IAddress | string, finish: IAddress | string) => Promise, locale: string | undefined, allStores: IStore[], isPro: boolean, grassProduct?: IGrassProduct, concreteOrder?: IConcreteOrder, settings?: { addOnePalletToPickup?: boolean; saveToShippingPayload?: boolean; useStoreAddress?: string; useDeliveryAddress?: boolean; useAvailableVracStores?: string[]; }, customPriceList?: ICustomPriceItem[]) => Promise; /** * Check if pro custom promo info should be shown for customer for a specific product. * @param userData * @param isPro * @param product * @param customMinPrice */ export declare const shouldShowProCustomPromo: (userData: ICustomer | null, isPro: boolean, product: any, customMinPrice?: ICustomPriceItem) => boolean; export declare const applyProCustomPromo: (decli: IIndexedDeclination, userData: ICustomer) => { discount_rules?: undefined; promo_price?: undefined; } | { discount_rules: IDiscountRule[]; promo_price: { currency: string; amount: number; }; }; export declare const getFormattedProdGR: (decli: IIndexedDeclination, productSlug: string, isPro?: boolean) => IIndexedDeclination; /** * Checks if a 0.00$ reg_price item should be considered "hidden" or not. * @param item - The indexedDecli or cartItem to check * @param productSlug - The parent product's slug (in case it is not found in item) * @param isUpsellOfInstallProd - Optionnal. If item is upsell of install product (additionnal fee for installation) */ export declare const shouldHideItemIfRegPriceIs0: (item: IIndexedDeclination | ICartItem, productSlug: string, isUpsellOfInstallProd?: boolean) => boolean;