UNPKG

shopperman

Version:

shopping cart ui for shopify stores

55 lines (54 loc) 1.54 kB
import { Product } from "./product"; import { CartItem } from "./cart-item"; import { CartOptions } from "./stores-interfaces"; /** * Default cart options */ export declare const defaultCartOptions: Partial<CartOptions>; /** * Shopping cart which tracks products and maintains a subtotal * - maintain a cart containing products and keeping track of quantities etc * - you must provide a catalog of all available items * - items with quantity 0 are considered "not in the cart" */ export declare class Cart { itemCatalog: CartItem[]; panelOpen: boolean; private readonly storageKey; private readonly omniStorage; private readonly currencyControl; constructor(opts: CartOptions); /** * Rehydrate the item catalog details from storage */ private loadFromStorage; /** * Save item catalog details to storage */ private saveToStorage; /** * Getter for items which are "in the cart" * - active items are cart items with quantity greater than zero */ readonly activeItems: CartItem[]; /** * Sum of cart item value */ readonly value: number; /** * Formatter price tag for the whole cart's value */ readonly price: string; /** * Toggle the cart panel open or closed */ togglePanelOpen(open?: boolean): boolean; /** * Remove all products from the cart */ clear(): void; /** * Get a cart item by providing the product inside */ getProductItem(product: Product): CartItem; }