UNPKG

@wallfar/ocd-studio-core-sdk

Version:

Helper SDK for our OneClick Studio modules

124 lines (123 loc) 4.63 kB
import type { WebshopConfig, Product, Collection, VariantOptions, UseProductReturn, Address, ShippingOption } from './types.js'; import { type MaybeRefOrGetter } from 'vue'; declare class Webshop { private config; private cart; private taxRate; private _shippingOptions; private _shippingOption; private _activePromoCode; private _collections; private _deliveryAddress; constructor(config: WebshopConfig); refreshCollections(): Promise<Collection[] | null>; refreshShippingOptions(): Promise<ShippingOption[] | null>; fetchProduct(slug: string): Promise<Product | null>; /** * Sends a notification to a user. * * @param product: Product created in the Products module from whitelabel core modules package. */ setProductSeo(product: Product): void; createConfigurator(product: Partial<Product>): { selection: any; getSelectedVariant: () => VariantOptions | undefined; getVariant: (variant: VariantOptions) => VariantOptions | undefined; }; addToCart(product: Partial<Product>, variant?: VariantOptions, quantity?: number): Promise<void>; removeFromCart(productId: string, variant?: VariantOptions): void; decreaseItem(productId: string, variant?: VariantOptions): void; updateQuantity(productId: string, variant: VariantOptions | undefined, newQty: number): void; private validatePromoCode; updateDeliveryAddress(updates: Partial<Address>): void; get cartItems(): { productId: string; title: string; slug: string; thumbnail?: string | undefined; price: number; currency: string; quantity: number; stock?: number | undefined; variant?: VariantOptions | undefined; }[]; get activePromoCode(): { id?: string | undefined; code: string; type: string; value?: number | undefined; minOrderAmount?: number | undefined; } | null; get collections(): import("vue").Ref<{ id?: string | undefined; title: string; description?: string | undefined; thumbnail?: string | undefined; slug: string; type: "manual" | "auto"; status: "published" | "draft"; conditions?: { field: string; operator: "==" | "!=" | "<" | ">" | "<=" | ">=" | "in" | "not-in" | "array-contains" | "array-contains-any"; value: any; }[] | undefined; seo?: { title?: string | undefined; description?: string | undefined; } | undefined; }[] | null, Collection[] | { id?: string | undefined; title: string; description?: string | undefined; thumbnail?: string | undefined; slug: string; type: "manual" | "auto"; status: "published" | "draft"; conditions?: { field: string; operator: "==" | "!=" | "<" | ">" | "<=" | ">=" | "in" | "not-in" | "array-contains" | "array-contains-any"; value: any; }[] | undefined; seo?: { title?: string | undefined; description?: string | undefined; } | undefined; }[] | null>; get itemCount(): number; get subtotal(): number; get deliveryAddress(): import("vue").ToRefs<{ firstName: string; lastName: string; company?: string | undefined; streetLine1: string; streetLine2?: string | undefined; streetLine3?: string | undefined; city: string; stateOrProvince?: string | undefined; countyOrDistrict?: string | undefined; postalCode: string; country: string; phoneNumber?: string | undefined; email?: string | undefined; instructions?: string | undefined; latitude?: number | undefined; longitude?: number | undefined; }>; get shippingOptions(): ShippingOption[]; get shippingOption(): string | null; set shippingOption(option: string | null); get shippingFee(): number; get discount(): number; get tax(): number; get total(): number; get country(): string; set country(val: string); applyPromoCode(code: string): Promise<import("./types.js").PromoCodeValidationResult>; createPaymentLink(): Promise<string | undefined>; removePromoCode(): void; clearCart(): void; formatPrice(price: number, currency?: string, locale?: string): string; useProduct(slug: MaybeRefOrGetter<string>): UseProductReturn; useCollection(slug: MaybeRefOrGetter<string>): any; } export default Webshop;