import { Awaitable, ReferenceData } from "./common"; /** * Type for cart item objects */ export type CartItem = { /** * Unique ID */ id: ReferenceData; /** * Size Identifier */ sizeId: ItemSize["id"]; /** * Quantity */ qty: number; }; /** * Type for item sizes */ export type ItemSize = { /** * Identifier for the size */ id: string; /** * Text for displaying the size */ label: string; }; /** * Provider for inventory related functionality. All functionality refers to your e-commerce solution. * * This provider is only used in the MDRC component and **not** in the VSC component. The VSC component * receives the size information in the {@link IGarmentInformationProvider.getSizes}. * * @group Host Providers * @group MDRC */ export interface IInventoryProvider { /** * Returns the available sizes for a garment with the given ID. * @param id Unique ID of the garment */ getSizes(id: ReferenceData): Awaitable>; } /** * This type provides backwards compatible type. * * @deprecated Use the new {@link IInventoryProvider} interface instead. */ export type InventoryProvider = IInventoryProvider; /** * The Commerce Provider is responsible for displaying product prices (including currency formatting) and handling the * `Add to Cart` functionality. To customise this behaviour, you must implement the following interface. * * @group Host Providers * @group VSC */ export interface ICommerceProvider { /** * Returns the currency for a given garment. * @param id Unique ID of the garment */ getCurrencyForId(id: ReferenceData): Awaitable; /** * Returns the price of a given garment. * @param id Unique ID of the garment */ getPriceForId(id: ReferenceData): Awaitable; /** * Returns the strike price of a given garment, if applicable * @param id Unique ID of the garment */ getStrikePriceForId(id: ReferenceData): Awaitable; /** * Returns if it is allowed to run add to cart operations in the MDRC. * If it is not set it will default to true! * @returns true if it is allowed to run add to cart operations in the MDRC */ allowAddToCart?(): Awaitable; /** * Returns true if it is allowed to run add to cart operation for a set of * garmetns. * If it is not set it will default to true! * @returns true if it is allowed to run add to cart operations in the MDRC */ allowAddToCartBundle?(): Awaitable; /** * Adds a list of items to the shopping cart * @param items Array of CartItem objects containing the ID, size and quantity of the products */ addToCart?(items: Array): Awaitable; /** * If this is implemented the function is called if the customer would like * to purchase the items identified in the items parameter. * * No size selection happened yet. * * This callback could show a screen for the user to select garment sizes, etc. * * @param items Array of IDs of the garments the customer would like to purchase */ addToCartIntend?(items: Array): Awaitable; } /** * This type provides backwards compatible type. * * @deprecated Use the new {@link ICommerceProvider} interface instead. */ export type CommerceProvider = ICommerceProvider;