@chiper-inc/ecommerce-lib
Version:
Chiper Inc Ecommerce Lib
71 lines (70 loc) • 2.43 kB
TypeScript
import { Price } from "./price";
import { Item, ItemType } from "./item";
import { Product, Measurement } from "./product";
import { Promotion } from "./promotion";
import { ItemQuantityError } from "./itemQuantityError";
import { New } from './new';
import { MaxQuantityHelper } from './helpers';
type CartOptions = {
items: Item[];
storeId: number;
warehouseId: number;
locationId: number;
status: "OK" | "IN_PROGRESS";
rate?: number;
};
declare class Cart {
private _items;
private _rate;
readonly storeId: number;
readonly warehouseId: number;
readonly locationId: number;
readonly status: "OK" | "IN_PROGRESS";
news: New[];
constructor({ items, storeId, warehouseId, status, locationId, rate }: CartOptions);
get rate(): number;
get items(): Item[];
get totalDollars(): number;
get total(): number;
get subtotal(): number;
removeItem(id: number | string): void;
addItem(item: Item): void;
get margin(): number;
getCartForWarehouse(warehouseId: number): Cart;
itemsByWarehouseId(warehouseId: number): Item[];
static from({ items, storeId, warehouseId, status, locationId }: any, rate: number, isBackend?: boolean, isOffline?: boolean): Cart;
static fromShopCart({ carts, storeId, warehouseId, status, locationId, rate }: any): Cart;
toJSON(): {
items: {
id: string | number;
warehouseId: number;
type: ItemType;
name: string;
stock: number;
quantity: number | undefined;
image: string;
medium: string;
packagingType: string;
minQuantity: number;
multipleQuantity: number;
total: number | null;
subtotal: number | null;
maxQuantity: number | undefined;
maximumQuantity: number | undefined;
regularPrice: number;
discountedPrice: number | undefined;
totalDollars: number | null;
regularPriceDolar: number;
}[];
storeId: number;
warehouseId: number;
status: "OK" | "IN_PROGRESS";
locationId: number;
total: number;
totalDollars: number;
subtotal: number;
news: New[];
rate: number;
};
}
export { Price, Item, Product, Promotion, Cart, CartOptions, ItemQuantityError, Measurement, MaxQuantityHelper, };