import IDeclination, { IDeclinationAttribute } from '../Interfaces/Declination'; import IDiscountRule, { IRuleDetails, RuleFieldEnum } from '../Interfaces/Rules/IDiscountRule'; import ICart, { CartErrorEnum, CartPromoAppliesToEnum, ICartItem, ICartItemCustomPrices, ICartPromoApplied, IIndexedDeclination, IIndexedTierPrincing } from '../Interfaces/Cart'; import Space from '../lib/Space'; /** * Get formatted array of cart promos applied to a specific cart * @param cartData */ export declare const getCartPromo: (cartData: ICart) => ICartPromoApplied[] | undefined; /** * Check if current cart promos applied contain a promo_code type promotion * @param cartData */ export declare const shouldCheckPromoCode: (cartData: ICart) => boolean; /** * Check if promo is expressed as a percentage * @param promo The promo to check. Works for cart applied promo as well as discount rule * @param options.includePaymentIncentiveInCheck Optionnal. If payement incentive promotions should also be included in check * @returns {boolean} */ export declare const isPromoAPercentage: (promo: ICartPromoApplied | IDiscountRule, options?: { includePaymentIncentiveInCheck?: boolean; defaultToPercent?: boolean; }) => boolean; export declare const getSubtotalWithoutProductPromos: (cartData: ICart, itemPromos: ICartPromoApplied[]) => number; export declare const getCartPromosByAppliesTo: (cartData: ICart) => { subtotal: ICartPromoApplied[]; items: ICartPromoApplied[]; afterTaxes: ICartPromoApplied[]; }; export declare const getAppliedAmountsForSubtotalPromosOnCart: (cartData: ICart) => { [discountID: string]: number; }; /** * Check if a discount rule applies to a specific declination * @param discount_rule - The discount rule to check * @param declination - The declination to compare * @param parentSlug - Optionnal. Used to check parent product slug with 'product' rule specifications. If not provided and 'product' rule found, returns true by default for rule check */ export declare const shouldApplyRuleToDeclination: (discount_rule: IDiscountRule, declination: IDeclination, parentSlug?: string) => boolean; /** * Check if a specific rule of a discount rule is respected * @param ruleDetail - The rule details object to check * @param cartValue - The value to compare with rule specifications */ export declare const getResultRuleDetail: (ruleDetail: IRuleDetails, cartValue: any, log?: boolean) => boolean; /** * Check if rule applied to product attributes is respected for specific declination attributes * @param attributeAndValues - The rule details object to check * @param arrDeclinationAttributes - The declinations attributes to compare */ export declare const checkAttributes: (attributeAndValues: IRuleDetails, arrDeclinationAttributes: IDeclinationAttribute[]) => boolean; export declare const getCartPromoType: (discount: IDiscountRule) => CartPromoAppliesToEnum; /** * Check if a cart still holds at least one item a promo could apply to, once its exclusion options are removed * @param cart - The cart to check * @param discount - The discount rule holding the exclusion options */ export declare const hasApplicableItemsForPromoExclusions: (cart: ICart, discount: IDiscountRule) => boolean; /** * Check if promo code can be applied to a specific cart * @param cart - The cart to check * @param promoCode - The discount rule with promo code to check */ export declare const checkPromoCodeEligibility: (cart: ICart, promoCode: IDiscountRule) => boolean; /** * Returns tier pricing step that should be applied for provided quantity, or undefined if none should apply * @param tierPricingToCheck - the indexed tier-pricing array to check * @param qte */ export declare const getTierPricingToApply: (tierPricingToCheck: IIndexedTierPrincing[] | undefined, qte: number) => IIndexedTierPrincing | undefined; /** * Converts tier-pricing found in discount_rule to IIndexedTierPricing. * @param discountRule - the tier-pricing tier discountRule to check * @param price - declinations regular price from which tier-pricing result is calculated * @param space * @param decimals - the amount of decimals to show on tier-pricing result */ export declare const applyTierPricing: (discountRule: IDiscountRule, price: number, space: Space, decimals?: number) => IIndexedTierPrincing[]; /** * Calculate new discount_price object for cart item base on qte and tier_pricing * @param item - the item to check * @param setOriginalPrice - if original_amount should be set instead of discount_price.amount * @param originalDecli - Optionnal. The IIndexedDeclination used to construct the cart item originally. */ export declare const getNewDiscountPriceFromTierPricing: (item: ICartItem, setOriginalPrice: boolean, originalDecli?: IIndexedDeclination) => ICartItemCustomPrices | null; /** * Get discounted price after applying discount rules to a provided price * @param discount_rules - The discount rules to apply * @param amount - The initial amount on which to apply discounts * @param space */ export declare const applyDiscountRulesOnProduct: (discount_rules: IDiscountRule[], amount: number, space: Space) => number | undefined; /** * Get result of discount rule discount on a provided amount * @param initial - The price on which to apply the discount * @param discountResultObj - The discount rule result object */ export declare const applyDiscountToPrice: (initial: number, discountResultObj: IDiscountRule['result']) => number; /** * Get sku(s) affected by a promo as an array of strings * @param valueToConvert - The sku or sku array associated with the promo * @returns And array of strings */ export declare const getSkuArrayForPromo: (valueToConvert: string | string[]) => string[]; /** * Returns a list of all skus where promo applied to specific products should apply. Check for both amount/percent_sku and amount/percent_category options. * @param cartItems - The current cart items * @param promoToCheck - The promo to check * @returns An array of strings */ export declare const getResultAppliedDiscountSkus: (cartItems: ICartItem[], promoToCheck: IDiscountRule) => string[]; /** * Creates array of all category level slugs for a cart item. * @param itemCategories - Value found in props cart.categories * @returns An array of strings */ export declare const getItemCategorySlugArray: (itemCategories: { [key: string]: string; } | undefined) => string[]; /** * Check if provided discount can be added to currently applied discounts for cart. * @param promoToCheck * @param currentPromos * @param isMultiPromo */ export declare const checkIfCanAddPromo: (promoToCheck: IDiscountRule, currentPromos: ICartPromoApplied[] | undefined, isMultiPromo: boolean) => { canAdd: boolean; reason?: CartErrorEnum; }; /** * Apply all valid discounts found in a specific cart's discount_rules props to cart * @param cart - The cart to check * @param isMultiPromo * @param forceShipping - If cart should be considered as a shipping cart, even if is_pickup is true */ export declare const applyDiscountToCart: (cart: ICart, isMultiPromo: boolean, forceShipping?: boolean, forcedPromos?: ICartPromoApplied[]) => ICart; /** * Get the ICartPromoApplied object for a specified discount_rule. Only works for promos that do not apply to products of certain categories/skus. * @param cart * @param discount */ export declare const getStandardCartPromoFromDiscount: (cart: ICart, discount: IDiscountRule) => ICartPromoApplied; /** Calculates the cumulative subtotal for all service/fee/discounted items in cart, including any applied promos. Usefull when calculating a promo's amount when all fees and services should be excluded. * @param items - The cart items to check * @param itemPromos - All currently active cartPromos that apply to items in cart. Sent seperatly in case local state is different from current cartData. * @param options - Which exclusions are active + rounding precision for line totals (defaults to 3) * @returns {number} */ export declare const getExcludedItemsSubtotal: (items: ICartItem[], itemPromos: ICartPromoApplied[], options: { excludeServices: boolean; excludeDiscounted: boolean; decimals?: number; }) => number; /** * Calculates the cumulative subtotal for all service/fee type items in cart, including any applied promos. Usefull when calculating a promo's amount when all fees and services should be excluded. * @param cartData - The cartData to check * @param allCurrentAppliedToItemPromos - All currently active cartPromos that apply to items in cart. Sent seperatly in case local state is different from current cartData. * @returns A number */ export declare const getOnlyServicesAndFeesSubtotal: (cartData: ICart, allCurrentAppliedToItemPromos: ICartPromoApplied[]) => number; /** * Checks if an incentive discount could (in theory) by added to provided cart, by checking found incentive discount's rule array. * @param cartData - The cart to check (checks discount_rules for incentive) * @param skipCheckFor - If certain rules should be ignore for check * @returns a boolean */ export declare const checkIfCouldApplyIncentivePromo: (cartData: ICart, skipCheckFor?: RuleFieldEnum[]) => boolean; /** * Calculates amount to be removed for payment incentive type promos. * @param cartData * @param checkDiscountRules - Optionnal. If cart discount_rules should be checked if cart_promos_applied does not have promo yet. */ export declare const getAfterTaxesPromosTotalAmount: (cartData: ICart, checkDiscountRules?: boolean) => number; /** * Returns cart_promos_applied corresponding to payment incentive, if found. Can also check in discount_rules if props provided * @param cartData * @param checkDiscountRules - Optionnal. If the function should check in cart discount_rules if nothing found in cart_promos_applied or if value differs between discount and promo applied */ export declare const getAfterTaxesPromoInCart: (cartData: ICart, checkDiscountRules?: boolean) => ICartPromoApplied | undefined; /** * Returns the information regarding the payment incentive promo if found in cart's discount_rules * @param cartData * @param checkForAllPaidByDiscounts Optionnal. If defined, will check all discounts if no specific incentive found */ export declare const getPaymentIncentiveDiscountInfo: (cartData: ICart, checkForAllPaidByDiscounts?: boolean) => { amount: number; isPercent: boolean; paymentTypes: string[]; } | undefined; export declare const getPaymentIncentiveDiscount: (discountRules: IDiscountRule[]) => IDiscountRule | undefined;