UNPKG

@automattic/wpcom-checkout

Version:
75 lines 3.63 kB
import { useTranslate } from 'i18n-calypso'; import type { LineItemType } from './types'; import type { ResponseCart, ResponseCartProduct } from '@automattic/shopping-cart'; export declare function getTotalLineItemFromCart(cart: ResponseCart): LineItemType; export declare function getCouponLineItemFromCart(responseCart: ResponseCart): LineItemType | null; export declare function getTaxLineItemFromCart(responseCart: ResponseCart): LineItemType | null; export declare function getTaxBreakdownLineItemsFromCart(responseCart: ResponseCart): LineItemType[]; export declare function getCreditsLineItemFromCart(responseCart: ResponseCart): LineItemType | null; export interface CostOverrideForDisplay { humanReadableReason: string; overrideCode: string; /** * The amount saved by this cost override in the currency's smallest unit. */ discountAmount: number; } export interface LineItemCostOverrideForDisplay { humanReadableReason: string; overrideCode: string; /** * The amount saved by this cost override in the currency's smallest unit. * * If not set, a number will not be displayed. This can be useful for some * types of discounts where the amount will be communicated in some other * manner. */ discountAmount?: number; } export declare function isUserVisibleCostOverride(costOverride: { does_override_original_cost: boolean; override_code: string; }): boolean; /** * Returns true if the product has an introductory offer which is for a * different term length than the term length of the product (eg: a 3 month * discount for an annual plan). */ export declare function doesIntroductoryOfferHaveDifferentTermLengthThanProduct(costOverrides: { override_code: string; }[] | undefined, introductoryOfferTerms: ResponseCartProduct['introductory_offer_terms'] | undefined, monthsPerBillPeriodForProduct: number | undefined | null): boolean; export declare function doesIntroductoryOfferHavePriceIncrease(product: ResponseCartProduct): boolean; export declare function filterCostOverridesForLineItem(product: ResponseCartProduct, translate: ReturnType<typeof useTranslate>, isStreamlinedPrice?: boolean): LineItemCostOverrideForDisplay[]; /** * Return a shopping-cart line item's cost before any discounts are applied. * * Note that this function returns the cost in the currency's smallest unit. */ export declare function getSubtotalWithoutDiscountsForProduct(product: ResponseCartProduct): number; /** * Return the shopping-cart subtotal before any discounts have been applied to * any cart item. * * This does not include credits which are not a discount; they reduce the * final price after taxes. * * Note that this function returns the cost in the currency's smallest unit. */ export declare function getSubtotalWithoutDiscounts(responseCart: ResponseCart): number; /** * Return the total savings from shopping-cart item discounts. * * This does not include credits which are not a discount; they reduce the * final price after taxes. * * Note that this function returns the cost in the currency's smallest unit. */ export declare function getTotalDiscountsWithoutCredits(responseCart: ResponseCart): number; export declare function doesPurchaseHaveFullCredits(cart: ResponseCart): boolean; export declare function isOverrideCodeIntroductoryOffer(overrideCode: string): boolean; /** * True if the billing/contact info is not filled in on a shopping cart (and it * needs to be filled in). */ export declare function isBillingInfoEmpty(responseCart: ResponseCart): boolean; //# sourceMappingURL=transformations.d.ts.map