type Primitive = number | string | boolean | bigint | symbol | null | undefined; type Tags = Record; type Context = Record; type Contexts = Record; interface SpanContextData { traceId: string; spanId: string; } interface Span { spanContext(): SpanContextData; end(): void; } interface SpanOptions { name: string; tags?: Tags; } interface Breadcrumb { type?: string; category?: string; message: string; level?: 'info' | 'warning' | 'error'; data?: Record; } interface CaptureContext { level?: 'info' | 'warning' | 'error'; tags?: Tags; contexts?: Contexts; } interface MonitoringClient { /** * Captures an exception event and sends it to Sentry. * @param error The error to capture * @param captureContext Optional additional data to attach to the Sentry e vent. * @returns the id of the captured Sentry event. */ captureException(error: unknown, captureContext?: CaptureContext): string; /** * Captures a message event and sends it to Sentry. * @param message The message to capture * @param captureContext Define the level of the message or pass in additional data to attach to the message. * @returns the id of the captured message. */ captureMessage(message: string, captureContext?: CaptureContext): string; /** * Wraps a function with a span and finishes the span after the function is done. The created span is the active span and will be used as parent by other spans created inside the function, as long as the function is executed while the scope is active. * @param spanOptions The options for the span * @param callback The function to wrap with a span * @returns The return value of the callback */ startSpan(spanOptions: SpanOptions, callback: (span: Span | undefined) => T): T; /** * Records a new breadcrumb which will be attached to future events. * Breadcrumbs will be added to subsequent events to provide more context on user's actions prior to an error or crash. * @param breadcrumb The breadcrumb to record. */ addBreadcrumb(breadcrumb: Breadcrumb): void; } type HostModule = { __type: 'host'; create(host: H): T; }; type HostModuleAPI> = T extends HostModule ? U : never; type Host$1 = { channel?: { observeState(callback: (props: unknown, environment: Environment) => unknown): { disconnect: () => void; } | Promise<{ disconnect: () => void; }>; }; environment?: Environment; /** * Optional name of the environment, use for logging */ name?: string; /** * Optional bast url to use for API requests, for example `www.wixapis.com` */ apiBaseUrl?: string; /** * Optional function to get a monitoring client */ getMonitoringClient?: () => MonitoringClient; /** * Possible data to be provided by every host, for cross cutting concerns * like internationalization, billing, etc. */ essentials?: { /** * The language of the currently viewed session */ language?: string; /** * The locale of the currently viewed session */ locale?: string; /** * Any headers that should be passed through to the API requests */ passThroughHeaders?: Record; }; }; type HTTPMethod = 'POST' | 'GET' | 'PUT' | 'DELETE' | 'PATCH' | 'HEAD' | 'OPTIONS'; type RESTFunctionDescriptor any = (...args: any[]) => any> = (httpClient: HttpClient) => T; interface HttpClient { request(req: RequestOptionsFactory): Promise>; fetchWithAuth: typeof fetch; wixAPIFetch: (relativeUrl: string, options: RequestInit) => Promise; getActiveToken?: () => string | undefined; } type RequestOptionsFactory = (context: any) => RequestOptions; type HttpResponse = { data: T; status: number; statusText: string; headers: any; request?: any; }; type RequestOptions<_TResponse = any, Data = any> = { method: HTTPMethod; url: string; data?: Data; params?: URLSearchParams; } & APIMetadata; type APIMetadata = { methodFqn?: string; entityFqdn?: string; packageName?: string; }; type BuildRESTFunction = T extends RESTFunctionDescriptor ? U : never; type EventDefinition = { __type: 'event-definition'; type: Type; isDomainEvent?: boolean; transformations?: (envelope: unknown) => Payload; __payload: Payload; }; declare function EventDefinition(type: Type, isDomainEvent?: boolean, transformations?: (envelope: any) => unknown): () => EventDefinition; type EventHandler = (payload: T['__payload']) => void | Promise; type BuildEventDefinition> = (handler: EventHandler) => void; type ServicePluginMethodInput = { request: any; metadata: any; }; type ServicePluginContract = Record unknown | Promise>; type ServicePluginMethodMetadata = { name: string; primaryHttpMappingPath: string; transformations: { fromREST: (...args: unknown[]) => ServicePluginMethodInput; toREST: (...args: unknown[]) => unknown; }; }; type ServicePluginDefinition = { __type: 'service-plugin-definition'; componentType: string; methods: ServicePluginMethodMetadata[]; __contract: Contract; }; declare function ServicePluginDefinition(componentType: string, methods: ServicePluginMethodMetadata[]): ServicePluginDefinition; type BuildServicePluginDefinition> = (implementation: T['__contract']) => void; declare const SERVICE_PLUGIN_ERROR_TYPE = "wix_spi_error"; type RequestContext = { isSSR: boolean; host: string; protocol?: string; }; type ResponseTransformer = (data: any, headers?: any) => any; /** * Ambassador request options types are copied mostly from AxiosRequestConfig. * They are copied and not imported to reduce the amount of dependencies (to reduce install time). * https://github.com/axios/axios/blob/3f53eb6960f05a1f88409c4b731a40de595cb825/index.d.ts#L307-L315 */ type Method = 'get' | 'GET' | 'delete' | 'DELETE' | 'head' | 'HEAD' | 'options' | 'OPTIONS' | 'post' | 'POST' | 'put' | 'PUT' | 'patch' | 'PATCH' | 'purge' | 'PURGE' | 'link' | 'LINK' | 'unlink' | 'UNLINK'; type AmbassadorRequestOptions = { _?: T; url?: string; method?: Method; params?: any; data?: any; transformResponse?: ResponseTransformer | ResponseTransformer[]; }; type AmbassadorFactory = (payload: Request) => ((context: RequestContext) => AmbassadorRequestOptions) & { __isAmbassador: boolean; }; type AmbassadorFunctionDescriptor = AmbassadorFactory; type BuildAmbassadorFunction = T extends AmbassadorFunctionDescriptor ? (req: Request) => Promise : never; declare global { // eslint-disable-next-line @typescript-eslint/consistent-type-definitions -- It has to be an `interface` so that it can be merged. interface SymbolConstructor { readonly observable: symbol; } } declare const emptyObjectSymbol: unique symbol; /** Represents a strictly empty plain object, the `{}` value. When you annotate something as the type `{}`, it can be anything except `null` and `undefined`. This means that you cannot use `{}` to represent an empty plain object ([read more](https://stackoverflow.com/questions/47339869/typescript-empty-object-and-any-difference/52193484#52193484)). @example ``` import type {EmptyObject} from 'type-fest'; // The following illustrates the problem with `{}`. const foo1: {} = {}; // Pass const foo2: {} = []; // Pass const foo3: {} = 42; // Pass const foo4: {} = {a: 1}; // Pass // With `EmptyObject` only the first case is valid. const bar1: EmptyObject = {}; // Pass const bar2: EmptyObject = 42; // Fail const bar3: EmptyObject = []; // Fail const bar4: EmptyObject = {a: 1}; // Fail ``` Unfortunately, `Record`, `Record` and `Record` do not work. See {@link https://github.com/sindresorhus/type-fest/issues/395 #395}. @category Object */ type EmptyObject = {[emptyObjectSymbol]?: never}; /** Returns a boolean for whether the two given types are equal. @link https://github.com/microsoft/TypeScript/issues/27024#issuecomment-421529650 @link https://stackoverflow.com/questions/68961864/how-does-the-equals-work-in-typescript/68963796#68963796 Use-cases: - If you want to make a conditional branch based on the result of a comparison of two types. @example ``` import type {IsEqual} from 'type-fest'; // This type returns a boolean for whether the given array includes the given item. // `IsEqual` is used to compare the given array at position 0 and the given item and then return true if they are equal. type Includes = Value extends readonly [Value[0], ...infer rest] ? IsEqual extends true ? true : Includes : false; ``` @category Type Guard @category Utilities */ type IsEqual = (() => G extends A & G | G ? 1 : 2) extends (() => G extends B & G | G ? 1 : 2) ? true : false; /** Filter out keys from an object. Returns `never` if `Exclude` is strictly equal to `Key`. Returns `never` if `Key` extends `Exclude`. Returns `Key` otherwise. @example ``` type Filtered = Filter<'foo', 'foo'>; //=> never ``` @example ``` type Filtered = Filter<'bar', string>; //=> never ``` @example ``` type Filtered = Filter<'bar', 'foo'>; //=> 'bar' ``` @see {Except} */ type Filter = IsEqual extends true ? never : (KeyType extends ExcludeType ? never : KeyType); type ExceptOptions = { /** Disallow assigning non-specified properties. Note that any omitted properties in the resulting type will be present in autocomplete as `undefined`. @default false */ requireExactProps?: boolean; }; /** Create a type from an object type without certain keys. We recommend setting the `requireExactProps` option to `true`. This type is a stricter version of [`Omit`](https://www.typescriptlang.org/docs/handbook/release-notes/typescript-3-5.html#the-omit-helper-type). The `Omit` type does not restrict the omitted keys to be keys present on the given type, while `Except` does. The benefits of a stricter type are avoiding typos and allowing the compiler to pick up on rename refactors automatically. This type was proposed to the TypeScript team, which declined it, saying they prefer that libraries implement stricter versions of the built-in types ([microsoft/TypeScript#30825](https://github.com/microsoft/TypeScript/issues/30825#issuecomment-523668235)). @example ``` import type {Except} from 'type-fest'; type Foo = { a: number; b: string; }; type FooWithoutA = Except; //=> {b: string} const fooWithoutA: FooWithoutA = {a: 1, b: '2'}; //=> errors: 'a' does not exist in type '{ b: string; }' type FooWithoutB = Except; //=> {a: number} & Partial> const fooWithoutB: FooWithoutB = {a: 1, b: '2'}; //=> errors at 'b': Type 'string' is not assignable to type 'undefined'. // The `Omit` utility type doesn't work when omitting specific keys from objects containing index signatures. // Consider the following example: type UserData = { [metadata: string]: string; email: string; name: string; role: 'admin' | 'user'; }; // `Omit` clearly doesn't behave as expected in this case: type PostPayload = Omit; //=> type PostPayload = { [x: string]: string; [x: number]: string; } // In situations like this, `Except` works better. // It simply removes the `email` key while preserving all the other keys. type PostPayload = Except; //=> type PostPayload = { [x: string]: string; name: string; role: 'admin' | 'user'; } ``` @category Object */ type Except = { [KeyType in keyof ObjectType as Filter]: ObjectType[KeyType]; } & (Options['requireExactProps'] extends true ? Partial> : {}); /** Returns a boolean for whether the given type is `never`. @link https://github.com/microsoft/TypeScript/issues/31751#issuecomment-498526919 @link https://stackoverflow.com/a/53984913/10292952 @link https://www.zhenghao.io/posts/ts-never Useful in type utilities, such as checking if something does not occur. @example ``` import type {IsNever, And} from 'type-fest'; // https://github.com/andnp/SimplyTyped/blob/master/src/types/strings.ts type AreStringsEqual = And< IsNever> extends true ? true : false, IsNever> extends true ? true : false >; type EndIfEqual = AreStringsEqual extends true ? never : void; function endIfEqual(input: I, output: O): EndIfEqual { if (input === output) { process.exit(0); } } endIfEqual('abc', 'abc'); //=> never endIfEqual('abc', '123'); //=> void ``` @category Type Guard @category Utilities */ type IsNever = [T] extends [never] ? true : false; /** An if-else-like type that resolves depending on whether the given type is `never`. @see {@link IsNever} @example ``` import type {IfNever} from 'type-fest'; type ShouldBeTrue = IfNever; //=> true type ShouldBeBar = IfNever<'not never', 'foo', 'bar'>; //=> 'bar' ``` @category Type Guard @category Utilities */ type IfNever = ( IsNever extends true ? TypeIfNever : TypeIfNotNever ); /** Extract the keys from a type where the value type of the key extends the given `Condition`. Internally this is used for the `ConditionalPick` and `ConditionalExcept` types. @example ``` import type {ConditionalKeys} from 'type-fest'; interface Example { a: string; b: string | number; c?: string; d: {}; } type StringKeysOnly = ConditionalKeys; //=> 'a' ``` To support partial types, make sure your `Condition` is a union of undefined (for example, `string | undefined`) as demonstrated below. @example ``` import type {ConditionalKeys} from 'type-fest'; type StringKeysAndUndefined = ConditionalKeys; //=> 'a' | 'c' ``` @category Object */ type ConditionalKeys = { // Map through all the keys of the given base type. [Key in keyof Base]-?: // Pick only keys with types extending the given `Condition` type. Base[Key] extends Condition // Retain this key // If the value for the key extends never, only include it if `Condition` also extends never ? IfNever, Key> // Discard this key since the condition fails. : never; // Convert the produced object into a union type of the keys which passed the conditional test. }[keyof Base]; /** Exclude keys from a shape that matches the given `Condition`. This is useful when you want to create a new type with a specific set of keys from a shape. For example, you might want to exclude all the primitive properties from a class and form a new shape containing everything but the primitive properties. @example ``` import type {Primitive, ConditionalExcept} from 'type-fest'; class Awesome { name: string; successes: number; failures: bigint; run() {} } type ExceptPrimitivesFromAwesome = ConditionalExcept; //=> {run: () => void} ``` @example ``` import type {ConditionalExcept} from 'type-fest'; interface Example { a: string; b: string | number; c: () => void; d: {}; } type NonStringKeysOnly = ConditionalExcept; //=> {b: string | number; c: () => void; d: {}} ``` @category Object */ type ConditionalExcept = Except< Base, ConditionalKeys >; /** * Descriptors are objects that describe the API of a module, and the module * can either be a REST module or a host module. * This type is recursive, so it can describe nested modules. */ type Descriptors = RESTFunctionDescriptor | AmbassadorFunctionDescriptor | HostModule | EventDefinition | ServicePluginDefinition | { [key: string]: Descriptors | PublicMetadata | any; }; /** * This type takes in a descriptors object of a certain Host (including an `unknown` host) * and returns an object with the same structure, but with all descriptors replaced with their API. * Any non-descriptor properties are removed from the returned object, including descriptors that * do not match the given host (as they will not work with the given host). */ type BuildDescriptors | undefined, Depth extends number = 5> = { done: T; recurse: T extends { __type: typeof SERVICE_PLUGIN_ERROR_TYPE; } ? never : T extends AmbassadorFunctionDescriptor ? BuildAmbassadorFunction : T extends RESTFunctionDescriptor ? BuildRESTFunction : T extends EventDefinition ? BuildEventDefinition : T extends ServicePluginDefinition ? BuildServicePluginDefinition : T extends HostModule ? HostModuleAPI : ConditionalExcept<{ [Key in keyof T]: T[Key] extends Descriptors ? BuildDescriptors : never; }, EmptyObject>; }[Depth extends -1 ? 'done' : 'recurse']; type PublicMetadata = { PACKAGE_NAME?: string; }; declare global { interface ContextualClient { } } /** * A type used to create concerete types from SDK descriptors in * case a contextual client is available. */ type MaybeContext = globalThis.ContextualClient extends { host: Host$1; } ? BuildDescriptors : T; declare global { /** * A global interface to set the exposure toggle for the SDK. * @example * ```ts * declare global { * interface SDKExposureToggle { * alpha: true; * } * } */ interface SDKExposureToggle { } } type WixNamespace = string; interface Channel { observeState(callback: (props: unknown, environment: Environment) => unknown): { disconnect: () => void; } | Promise<{ disconnect: () => void; }>; } interface WebsiteChannel extends Channel { invoke: (args: { namespace: WixNamespace; method: string; args: unknown[]; }) => Promise; getAccessToken: () => Promise; } type Host = { channel: WebsiteChannel; environment?: Environment; }; /** * An object representing an address. */ interface CartAddress { /** * First name. * @requiredField firstName */ firstName: string; /** * Last name. * @requiredField lastName */ lastName: string; /** * Email address. * @requiredField email */ email: string; /** * Phone number. * @requiredField phone */ phone: string; /** * Address. * @requiredField address */ address: string; } /** * An object representing a coupon applied in a shopping cart. */ interface CartAppliedCoupon { /** * Coupon code. * @requiredField code */ code: string; /** * Coupon unique identifier. * @requiredField couponId */ couponId: string; /** * Coupon name. * @requiredField name */ name: string; /** * Type of coupon. * One of: * * + `"BuyXGetY"` * + `"FixedPriceAmount"` * + `"FreeShipping"` * + `"MoneyOffAmount"` * + `"PercentOffRate"` * @requiredField couponType */ couponType: string; /** * Value of the coupon discount. * @requiredField discountValue */ discountValue: string; } /** * An object representing a visitor who abandoned a shopping cart. */ interface CartBuyerInfo { /** * Buyer's unique ID. * @requiredField id */ id: string; /** * Buyer's email address. * @requiredField email */ email: string; /** * Buyer's first name. * @requiredField firstName */ firstName: string; /** * Buyer's last name. * @requiredField lastName */ lastName: string; /** * Buyer's identity. * One of: * * + `"ADMIN"`: Buyer is the site owner. * + `"MEMBER"`: Buyer is a logged-in site member. * + `"VISITOR"`: Buyer is not logged in. * + `"CONTACT"`: A contact has been created for the buyer. * @requiredField identityType */ identityType: string; /** * Buyer's phone number. * @requiredField phone */ phone: string; } /** * An object representing a custom text field. */ interface CartCustomTextField { /** * Field title. * @requiredField title */ title: string; /** * Field value. * @requiredField value */ value: string; } /** * An object representing a line item in a shopping cart. */ interface CartLineItem { /** * Cart line item ID. * @requiredField id */ id: number; /** * Name of the line item. * @requiredField name */ name: string; /** * Notes about the line item. * @requiredField notes */ notes: string; /** * Line item price. * @requiredField price */ price: string; /** * Line item product ID. * @requiredField productId */ productId: string; /** * Line item quantity. * @requiredField quantity */ quantity: number; /** * Line item stock keeping unit. * @requiredField sku */ sku: string; /** * Total price charged to the customer for all line items after any applicable discounts. * @requiredField totalPrice */ totalPrice: string; /** * Line item weight. * @requiredField weight */ weight: string; /** * Type of the line item. * One of: * * + `"DIGITAL"`: Digital item. * + `"PHYSICAL"`: Physical item. * + `"CUSTOM_AMOUNT_ITEM"`: Item with a custom price. * + `"UNSPECIFIED"`: Type can't be classified due to an error. * @requiredField lineItemType */ lineItemType: string; /** * Line item options. * @requiredField options * @servicePath wix-stores-frontend.Option */ options: Option[]; /** * Media item. * @requiredField mediaItem * @servicePath wix-stores-frontend.CartMediaItem */ mediaItem: CartMediaItem; /** * Custom text. * @requiredField customTextFields * @servicePath wix-stores-frontend.CartCustomTextField */ customTextFields: CartCustomTextField[]; } /** * An object representing a line item's primary media. */ interface CartMediaItem { /** * Media item type. Currently only `"IMAGE"` type supported. * @requiredField type */ type: string; /** * Media item source for media uploaded to Wix (wix:image, wix:video or external URL). * @requiredField src */ src: string; } /** * An object representing a shopping cart. */ interface CartObj { /** * Unique identifier of the shopping cart. * @requiredField _id */ _id: string; /** * Coupon applied in the shopping cart. * @requiredField appliedCoupon * @servicePath wix-stores-frontend.CartAppliedCoupon */ appliedCoupon: CartAppliedCoupon; /** * Cart billing address. * @requiredField billingAddress * @servicePath wix-stores-frontend.CartAddress */ billingAddress: CartAddress; /** * The buyer's information. * @requiredField buyerInfo * @servicePath wix-stores-frontend.CartBuyerInfo */ buyerInfo: CartBuyerInfo; /** * Cart status. Either `"INCOMPLETE"` or `"COMPLETE"`. * @requiredField status */ status: string; /** * Currency of the shopping cart. * @requiredField currency * @servicePath wix-stores-frontend.Currency */ currency: Currency; /** * The shopping cart's shipping information. * @requiredField shippingInfo * @servicePath wix-stores-frontend.CartShippingInfo */ shippingInfo: CartShippingInfo; /** * Items in the shopping cart. * @requiredField lineItems * @servicePath wix-stores-frontend.CartLineItem */ lineItems: CartLineItem[]; /** * The shopping cart's totals. * @requiredField totals * @servicePath wix-stores-frontend.OrderTotals */ totals: OrderTotals; /** * The order's units of weight. One of: `"KG"`, `"LB"`, or `"UNSPECIFIED_WEIGHT_UNIT"`. * @requiredField weightUnit */ weightUnit: string; } /** * An object representing shipping information. */ interface CartShippingInfo { /** * Shipment address. * @servicePath wix-stores-frontend.CartAddress */ shippingAddress?: CartAddress; /** * Pickup address. * @servicePath wix-stores-frontend.CartAddress */ pickupInfo?: CartAddress; } /** * An object representing a currency. */ interface Currency { /** * The currency code. * @requiredField currency */ currency: string; } /** * An object representing a media item. * * The `src` property of a `MediaItem` can be an image or video from the [Media Manager](https://support.wix.com/en/article/about-the-media-manager). * * The image source format for Media Manager images is: * `wix:image://v1//#originWidth=&originHeight=[&watermark=]` * * The video source format is: * `wix:video://v1//#posterUri=&posterWidth=&posterHeight=` */ interface MediaItem { /** * Media item ID. * @requiredField id */ id: string; /** * Media item title. * @requiredField title */ title: string; /** * Media item description. * @requiredField description */ description: string; /** * Media items type. Can be "image" or "video." * @requiredField type */ type: string; /** * Media item URL. * @requiredField src */ src: string; /** * Thumbnail URL for videos only. */ thumbnail?: string; } /** * An object representing a line item option. */ interface Option { /** * Name of the product option. * @requiredField option */ option: string; /** * Selected option. * @requiredField selection */ selection: string; } /** * An object representing an order's totals. */ interface OrderTotals { /** * The subtotal of all the order's line items, excluding tax. * @requiredField subtotal */ subtotal: number; /** * The total shipping price, including tax. * @requiredField shipping */ shipping: number; /** * The total amount of tax. * @requiredField tax */ tax: string; /** * The total calculated discount amount. * @requiredField discount */ discount: number; /** * The total price. * @requiredField total */ total: number; /** * The total weight of the order's items. * @requiredField weight */ weight: number; /** * The total quantity of the the order's line items. * @requiredField quantity */ quantity: number; } /** * An object representing an option for a store product. */ interface ProductOption { /** * Option type. Either `"color"` or `"drop_down"`. * @requiredField optionType */ optionType: string; /** * Option name. * @requiredField name */ name: string; /** * Option choices. * @requiredField choices * @servicePath wix-stores-frontend.ProductOptionsChoice */ choices: ProductOptionsChoice[]; } /** * An object representing all the available options for a store product, such as "Size" or "Color". * * An option can't be changed if it has choices and variants. To change an option, reset its variants with `resetAllProductVariantData()` or `resetVariantData()`. For each option, you can define a maximum of 6 choices. */ interface ProductOptions { /** * Name of the option. This key name *  is dependent on the options added to the product. For example, if a product has a size * option, this key will be something like `"Size"`. * * `optionKey` isn't case-sensitive. Therefore the values for the option keys "`Size`", "`SIZE`", and "`size`" are combined. * @requiredField optionKey * @servicePath wix-stores-frontend.ProductOption */ optionKey: ProductOption; } /** * An object returned by `getProductOptionsAvailability()` representing the availability of a product. */ interface ProductOptionsAvailability { /** * Whether the product with the specified option choices is available for purchase. * @requiredField availableForPurchase */ availableForPurchase: boolean; /** * An object representing all the available options for a store product. * @requiredField productOptions * @servicePath wix-stores-frontend.ProductOptions */ productOptions: ProductOptions; /** * Main product media item (image or video) URL. * @requiredField mainMedia */ mainMedia: string; /** * List of product media items. * @requiredField mediaItems * @servicePath wix-stores-frontend.MediaItem */ mediaItems: MediaItem; /** * The variant of the product selected using the specified option choices if there is one. * @requiredField selectedVariant * @servicePath wix-stores-frontend.ProductOptionsAvailabilitySelectedVariant */ selectedVariant: ProductOptionsAvailabilitySelectedVariant; } /** * An object representing the product variant selected with `getProductOptionsAvailability()`. */ interface ProductOptionsAvailabilitySelectedVariant { /** * Product variant stock keeping unit value. * @requiredField sku */ sku: string; /** * Product variant currency. * @requiredField currency */ currency: string; /** * Product variant price. The variant price must be greater than its discount. * @requiredField price */ price: number; /** * Discounted product variant price. * @requiredField discountedPrice */ discountedPrice: number; /** * Product variant price formatted with the currency. * @requiredField formattedPrice */ formattedPrice: string; /** * Discounted product variant price formatted with the currency. * @requiredField formattedDiscountedPrice */ formattedDiscountedPrice: string; /** * Whether the product variant is shown in the store. * @requiredField visible */ visible: boolean; /** * Whether the product variant is in stock. * @requiredField inStock */ inStock: boolean; /** * Product variant weight. * @requiredField weight */ weight: number; } /** * An object representing an options choice for a store product, such as choice "Small" for the option "Size." * * You can define between 1 and 30 choices for each option. */ interface ProductOptionsChoice { /** * Choice value. * @requiredField value */ value: number; /** * Choice description. * @requiredField description */ description: number; /** * Choice media. * @requiredField media * @servicePath wix-stores-frontend.ProductOptionsChoiceMedia */ media: ProductOptionsChoiceMedia; /** * Whether the product with this choice is in stock. * @requiredField inStock */ inStock: boolean; /** * Whether the product with this option is visible. * @requiredField visible */ visible: boolean; } /** * An object representing the choice media. */ interface ProductOptionsChoiceMedia { /** * Main choice media item (image or video thumbnail) URL. * @requiredField mainMedia */ mainMedia: string; /** * List of choice media items. * @requiredField mediaItems * @servicePath wix-stores-frontend.MediaItem */ mediaItems: MediaItem; } /** * An object representing the selection of specific variants of a product. Use only one of * `choices` or `variantIds`. */ interface ProductVariantOptions { /** * Choices of the retrieved variants. */ choices?: object; /** * IDs of the variants to retrieve. */ variantIds?: string[]; } interface QuickViewOptions { /** * Product quantity to be displayed in the Quick View. Defaults to 1. * @requiredField quantity */ quantity: number; } /** * An object containing variant information to use when creating or updating variants. */ interface VariantInfo { /** * Variant currency. * @requiredField currency */ currency: string; /** * Variant price. The variant price must be greater than its discount. If the variant price has been updated, changes to the product price don't affect the variant price. * @requiredField price */ price: number; /** * Discounted variant price. * @requiredField discountedPrice */ discountedPrice: number; /** * Variant price formatted with the currency. * @requiredField formattedPrice */ formattedPrice: string; /** * Discounted variant price formatted with the currency. * @requiredField formattedDiscountedPrice */ formattedDiscountedPrice: string; /** * Price per unit. * @requiredField pricePerUnit */ pricePerUnit: number; /** * Price per unit formatted with currency symbol. * @requiredField formattedPricePerUnit */ formattedPricePerUnit: string; /** * Variant weight. * @requiredField weight */ weight: number; /** * Variant stock keeping unit value. * @requiredField sku */ sku: string; /** * Whether the variant is visible in the store. * @requiredField visible */ visible: boolean; } /** * An object representing a product variant item. */ interface VariantItem { /** * Unique variant ID. * @requiredField _id */ _id: string; /** * Choices of the retrieved variant in the form of an object containing a `key:value` pair for each variant choice. For example, if a variant has a size option, this key value will be something like "Size" and its value will be something like "Large". * @requiredField choices */ choices: object; /** * Variant information. * @requiredField variant * @servicePath wix-stores-frontend.VariantInfo */ variant: VariantInfo; } /** * Function that runs when a cart changes. * @param cart - The changed cart. * @requiredField cart * @servicePath wix-stores-frontend.CartObj */ type CartChangedHandler = (cart: CartObj) => void; /** * **Deprecated.** * The `wix-stores-frontend.Cart` module will continue to work, but newer functions are available at * [`wix-ecom-frontend`](https://dev.wix.com/docs/velo/api-reference/wix-ecom-frontend/introduction) and [`wix-ecom-backend.CurrentCart`](https://dev.wix.com/docs/velo/api-reference/wix-ecom-backend/current-cart/introduction). * * > **Note:** * > The `wix-stores-frontend.Cart` modules is deprecated. * > If you're already using this modules in your code, it will continue to work. * > To stay compatible with future changes, update your code * > with the migration instructions in this module's functions. * * The `wix-stores-frontend.Cart` module contains functionality for working with a * site's cart from frontend code. * * To use the Wix Stores Cart API, import `{ cart }` from the `wix-stores-frontend` module: * * ```javascript * import { cart } from 'wix-stores-frontend'; * ``` */ interface Cart { /** * **Deprecated.** * This function will continue to work, but a newer version is available at * [`wix-ecom-backend.currentCart.addToCurrentCart()`](https://dev.wix.com/docs/velo/api-reference/wix-ecom-backend/current-cart/add-to-current-cart). * * > #### Migration Instructions * > * > If this function is already in your code, it will continue to work. * > To stay compatible with future changes, migrate to * > [`wix-ecom-backend.currentCart.addToCurrentCart()`](https://dev.wix.com/docs/velo/api-reference/wix-ecom-backend/current-cart/add-to-current-cart). * > * > To migrate to the new function: * > * > 1. Add the new import statement: * > * > ```javascript * > import { currentCart } from "wix-ecom-backend"; * > ``` * > * > 2. Look for any code that uses `cart.addProducts()`, * > and replace it with `currentCart.addToCurrentCart()`. * > Update your code to work with the new `currentCart.addToCurrentCart()` call and response properties. * > * > To help with updating your code to work with the new `currentCart.addToCurrentCart()` properties, learn more about [integrating Wix Stores with the Wix eCommerce](https://dev.wix.com/docs/velo/api-reference/wix-stores-backend/e-commerce-integration). * > * > 3. Test your changes to make sure your code behaves as expected. * * Adds one or more products to the cart. * * The `addProducts()` function returns a Promise that is resolved when the * specified products are added to the cart. * * Use the `quantity` property of each `AddToCartItem` object that is * passed to the products parameter to add one or more products to the cart at one time. * * Use the `options` property of each `AddToCartItem` object that is * passed to the products parameter to specify the product options to choose when adding * the product to the cart. For example, if a product comes in different sizes, you can * specify the size that should be added to the cart. If the product you are adding to the * cart has options, you must specify which options should be chosen. * * You can see a product's option information in the `productOptions` field in the **Stores/Products** collection. * * You can use [`product.getOptionsAvailability()`](https://www.wix.com/velo/reference/wix-stores-frontend/product/getoptionsavailability) * to determine if an item with specific options is available for purchase. * * > **Note:** If you use [`wix-stores-backend.createProduct()`](https://www.wix.com/velo/reference/wix-stores-backend/createproduct) immediately before adding that product to the cart, we suggest [setting a timeout](https://developer.mozilla.org/en-US/docs/Web/API/setTimeout) for `"1000"` milliseconds (1 second) before calling `cart.addProducts()`. While this slows down the operation slightly, it also ensures proper retrieval of the newly created product before adding it to the cart. * @param products - One or more products to be added to the cart. * @requiredField products * @servicePath wix-stores-frontend.Cart.AddToCartItem * @returns Fulfilled - The updated cart with added products. * @servicePath wix-stores-frontend.CartObj */ addProducts(products: AddToCartItem[]): Promise; /** * **Deprecated.** * This function will continue to work, but a newer version is available at * [`wix-ecom-backend.currentCart.updateCurrentCart()`](https://dev.wix.com/docs/velo/api-reference/wix-ecom-backend/current-cart/update-current-cart). * * > #### Migration Instructions * > * > If this function is already in your code, it will continue to work. * > To stay compatible with future changes, migrate to * > [`wix-ecom-backend.currentCart.updateCurrentCart()`](https://dev.wix.com/docs/velo/api-reference/wix-ecom-backend/current-cart/update-current-cart). * > * > To migrate to the new function: * > * > 1. Add the new import statement: * > * > ```javascript * > import { currentCart } from "wix-ecom-backend"; * > ``` * > * > 2. Look for any code that uses `cart.applyCoupon()`, * > and replace it with `currentCart.updateCurrentCart()`. * > Update your code to work with the new `currentCart.updateCurrentCart()` * > call and response properties. * > * > 3. Test your changes to make sure your code behaves as expected. * * Adds and applies a coupon to the cart. * * The `applyCoupon()` function returns a Promise that resolves to the current * site visitor's cart when the specified coupon has been applied. * * The cart can only hold one coupon. If a coupon is already applied to the cart, passing a different `couponCode` to `applyCoupon()` will replace the existing one. * * > **Note:** When [editing a site as a contributor](https://support.wix.com/en/article/velo-working-with-contributors), `applyCoupon()` will only work when viewing the live site. * @param couponCode - The code of the coupon to be applied to the cart. * @requiredField couponCode * @returns Fulfilled - The updated cart. * @servicePath wix-stores-frontend.CartObj */ applyCoupon(couponCode: string): Promise; /** * **Deprecated.** * This function will continue to work, but a newer version is available at * [`wix-ecom-backend.CurrentCart.getCurrentCart()`](https://www.wix.com/velo/reference/wix-ecom-backend/currentcart/getcurrentcart). * * We recommend you migrate to the new [Wix eCommerce APIs](https://www.wix.com/velo/reference/wix-ecom-backend/introduction) as soon as possible. * * > #### Migration Instructions * > * > If this function is already in your code, it will continue to work. * > To stay compatible with future changes, migrate to * > [`wix-ecom-backend.CurrentCart.getCurrentCart()`](https://dev.wix.com/docs/velo/api-reference/wix-ecom-backend/currentcart/getcurrentcart). * > * > The `wix-ecom-backend.CurrentCart.getCurrentCart()` function works from both backend and frontend code. * > * > To migrate to the new function: * > * > 1. Add the new import statement: * > * > ```javascript * > import { currentCart } from 'wix-ecom-backend'; * > ``` * > * > 2. Look for any code that uses `cart.getCurrentCart()`, * > and replace it with `currentCart.getCurrentCart()`. * > Update your code to work with the new `currentCart.getCurrentCart()` * > call and response properties. * > For more info about the differences between the Stores Cart and eCommerce Cart, refer to the [cart conversion table](https://www.wix.com/velo/reference/wix-ecom-backend/cart/stores-to-ecommerce-cart-conversion-table). * > * > 3. Test your changes to make sure your code behaves as expected. * * Gets the current site visitor's shopping cart. * * The `getCurrentCart()` function returns a Promise that resolves to the current * site visitor's shopping cart. * * @returns Fulfilled - The retrieved cart. * @servicePath wix-stores-frontend.CartObj */ getCurrentCart(): Promise; /** * **Deprecated.** * This function will continue to work, but will soon be deprecated. Hiding the Mini Cart or Side Cart can be done by clicking anywhere else on the page. * * Hides the Mini Cart. * * The `hideMiniCart()` function hides the Mini Cart. * Learn more about the [Mini Cart](https://support.wix.com/en/article/customizing-the-cart-page). * * > **Note:** This API will fail when viewing the site on mobile because there is no Mini Cart on the mobile site. */ hideMiniCart(): Promise; /** * **Deprecated.** * This function will continue to work, but a newer version is available at * [`wix-ecom-frontend.onCartChange()`](https://dev.wix.com/docs/velo/api-reference/wix-ecom-frontend/on-cart-change). * * > #### Migration Instructions * > * > If this function is already in your code, it will continue to work. * > To stay compatible with future changes, migrate to * > [`wix-ecom-frontend.onCartChange()`](https://dev.wix.com/docs/velo/api-reference/wix-ecom-frontend/on-cart-change). * > * > To migrate to the new function: * > * > 1. Add the new import statement: * > * > ```javascript * > import wixEcomFrontend from "wix-ecom-frontend"; * > ``` * > * > 2. Look for any code that uses `cart.onChange()`, * > and replace it with `wixEcomFrontend.onCartChange()`. * > The new `onCartChange()` event handler does not return the changed cart. Update your code accordingly. * > * > 3. Test your changes to make sure your code behaves as expected. * * * An event handler that is triggered when items are added or removed from a cart. * * The `onChange()` function is a client-side event handler invoked every time the cart changes. It takes a callback function which receives the new `Cart` object as a parameter. * * > **Notes:** * > + Use `onChange()` in the global site code file (masterPage.js). This ensures the event is triggered when a change to the cart is made on any page. Learn more about [global (site) code](https://support.wix.com/en/article/velo-working-with-the-velo-sidebar#global-site). * > + The `onChange()` function can only be used once a page has loaded. Therefore, you must use it in code that is contained in or is called from the [onReady()](https://dev.wix.com/docs/velo/api-reference/$w/on-ready) event handler or any element event handler. * > + When [editing a site as a contributor](https://support.wix.com/en/article/velo-working-with-contributors), `onChange()` will only work when viewing the live site. * @param handler - The name of the function to run when a cart changes. * @requiredField handler * @servicePath wix-stores-frontend.CartChangedHandler */ onChange(handler: CartChangedHandler): Promise; /** * **Deprecated.** * This function will continue to work, but a newer version is available at * [`wix-ecom-backend.currentCart.removeCouponFromCurrentCart()`](https://dev.wix.com/docs/velo/api-reference/wix-ecom-backend/current-cart/remove-coupon-from-current-cart). * * > #### Migration Instructions * > * > If this function is already in your code, it will continue to work. * > To stay compatible with future changes, migrate to * > [`wix-ecom-backend.currentCart.removeCouponFromCurrentCart()`](https://dev.wix.com/docs/velo/api-reference/wix-ecom-backend/current-cart/remove-coupon-from-current-cart). * > * > To migrate to the new function: * > * > 1. Add the new import statement: * > * > ```javascript * > import { currentCart } from "wix-ecom-backend"; * > ``` * > * > 2. Look for any code that uses `cart.removeCoupon()`, * > and replace it with `currentCart.removeCouponFromCurrentCart()`. * > Update your code to work with the new `currentCart.removeCouponFromCurrentCart()` * > call and response properties. * > * > 3. Test your changes to make sure your code behaves as expected. * * Removes the coupon currently applied to the cart. * * The `removeCoupon()` function returns a Promise that resolves to the current * site visitor's cart when the currently applied coupon has been removed. * * > **Note:** When [editing a site as a contributor](https://support.wix.com/en/article/velo-working-with-contributors), `removeCoupon()` will only work when viewing the live site. * * @returns Fulfilled - The updated cart. * @servicePath wix-stores-frontend.CartObj */ removeCoupon(): Promise; /** * **Deprecated.** * This function will continue to work, but a newer version is available at * [`wix-ecom-backend.currentCart.removeLineItemsFromCurrentCart()`](https://dev.wix.com/docs/velo/api-reference/wix-ecom-backend/current-cart/remove-line-items-from-current-cart). * * > #### Migration Instructions * > * > If this function is already in your code, it will continue to work. * > To stay compatible with future changes, migrate to * > [`wix-ecom-backend.currentCart.removeLineItemsFromCurrentCart()`](https://dev.wix.com/docs/velo/api-reference/wix-ecom-backend/current-cart/remove-line-items-from-current-cart). * > * > To migrate to the new function: * > * > 1. Add the new import statement: * > * > ```javascript * > import { currentCart } from "wix-ecom-backend"; * > ``` * > * > 2. Look for any code that uses `cart.removeProduct()`, * > and replace it with `currentCart.removeLineItemsFromCurrentCart()`. * > Update your code to work with the new `currentCart.removeLineItemsFromCurrentCart()` * > call and response properties. * > * > 3. Test your changes to make sure your code behaves as expected. * * Removes a specified product from the cart. * * The `removeProduct()` function returns a Promise that resolves to the * updated cart after the product is removed. * Every line item in a cart has an ID. Pass this to `removeProduct()` to remove that line item/product from the cart. * * > **Notes:** * > + `removeProduct()` does not decrement the line item's quantity, it removes the line item/product altogether. * > + When [editing a site as a contributor](https://support.wix.com/en/article/velo-working-with-contributors), `removeProduct()` will only work when viewing the live site. * @param cartLineItemId - ID of the cart line item to remove. * @requiredField cartLineItemId * @returns Fulfilled - The updated cart. * @servicePath wix-stores-frontend.CartObj */ removeProduct(cartLineItemId: number): Promise; /** * **Deprecated.** * This function will continue to work, but a newer version is available at * [`wix-ecom-frontend.openSideCart()`](https://dev.wix.com/docs/velo/api-reference/wix-ecom-frontend/open-side-cart). * * > #### Migration Instructions * > * > If this function is already in your code, it will continue to work. * > To stay compatible with future changes, migrate to * > [`wix-ecom-frontend.openSideCart()`](https://dev.wix.com/docs/velo/api-reference/wix-ecom-frontend/open-side-cart). * > * > To migrate to the new function: * > * > 1. Add the new import statement: * > * > ```javascript * > import wixEcomFrontend from "wix-ecom-frontend"; * > ``` * > * > 2. Look for any code that uses `cart.showMiniCart()`, * > and replace it with `wixEcomFrontend.openSideCart()`. * > * > 3. Test your changes to make sure your code behaves as expected. * * Shows the Mini Cart. * * The `showMiniCart()` function displays the Mini Cart. * Learn more about the [Mini Cart](https://support.wix.com/en/article/customizing-the-cart-page). * > **Note:** This API will fail when viewing the site on mobile because there is no Mini Cart on the mobile site. */ showMiniCart(): Promise; /** * **Deprecated.** * This function will continue to work, but a newer version is available at * [`wix-ecom-backend.currentCart.updateCurrentCartLineItemQuantity()`](https://dev.wix.com/docs/velo/api-reference/wix-ecom-backend/current-cart/update-current-cart-line-item-quantity). * * > #### Migration Instructions * > * > If this function is already in your code, it will continue to work. * > To stay compatible with future changes, migrate to * > [`wix-ecom-backend.currentCart.updateCurrentCartLineItemQuantity()`](https://dev.wix.com/docs/velo/api-reference/wix-ecom-backend/current-cart/update-current-cart-line-item-quantity). * > * > To migrate to the new function: * > * > 1. Add the new import statement: * > * > ```javascript * > import { currentCart } from "wix-ecom-backend"; * > ``` * > * > 2. Look for any code that uses `cart.updateLineItemQuantity()`, * > and replace it with `currentCart.updateCurrentCartLineItemQuantity()`. * > Update your code to work with the new `currentCart.updateCurrentCartLineItemQuantity()` * > call and response properties. * * Updates the quantity of a specified line item in the cart. * * The `updateLineItemQuantity()` function returns a Promise that resolves to the current * site visitor's cart when the specified line item's quantity has been updated. * * > **Note:** When [editing a site as a contributor](https://support.wix.com/en/article/velo-working-with-contributors), `updateLineItemQuantity()` will only work when viewing the live site. * @param cartLineItemId - ID of the cart line item to update. * @requiredField cartLineItemId * @param quantity - Line item's new quantity. * @requiredField quantity * @returns Fulfilled - The updated cart. * @servicePath wix-stores-frontend.CartObj */ updateLineItemQuantity(cartLineItemId: number, quantity: number): Promise; } /** * An object used when adding one or more products to the cart. */ interface AddToCartItem { /** * ID of the product to add to the cart. * @requiredField productId */ productId: string; /** * Number of product units to add to the cart. * @requiredField quantity */ quantity: number; /** * Specific product options to add to the cart. * If the product you're adding has options, you must specify which options to add. * @servicePath wix-stores-frontend.Cart.AddToCartOptions */ options?: AddToCartOptions; } /** * An object used when adding a product to the cart with options. */ interface AddToCartOptions { /** * Product options to use when adding the * product to the cart. The object contains `key:value` pairs where the key is the option name and the value is the chosen option value. */ choices?: object; /** * Custom text fields to use when adding the product to the cart. * @servicePath wix-stores-frontend.Cart.CustomTextField */ customTextFields?: CustomTextField[]; } /** * An object used to pass a custom text field when adding a product to * the cart with options. */ interface CustomTextField { /** * Custom text field title. * @requiredField title */ title: string; /** * Custom text field value. * @requiredField value */ value: string; } /** * **Deprecated.** * This function will continue to work, but a newer version is available at * [`wix-ecom-backend.currentCart.addToCurrentCart()`](https://dev.wix.com/docs/velo/api-reference/wix-ecom-backend/current-cart/add-to-current-cart). * * > #### Migration Instructions * > * > If this function is already in your code, it will continue to work. * > To stay compatible with future changes, migrate to * > [`wix-ecom-backend.currentCart.addToCurrentCart()`](https://dev.wix.com/docs/velo/api-reference/wix-ecom-backend/current-cart/add-to-current-cart). * > * > To migrate to the new function: * > * > 1. Add the new import statement: * > * > ```javascript * > import { currentCart } from "wix-ecom-backend"; * > ``` * > * > 2. Look for any code that uses `cart.addProducts()`, * > and replace it with `currentCart.addToCurrentCart()`. * > Update your code to work with the new `currentCart.addToCurrentCart()` call and response properties. * > * > To help with updating your code to work with the new `currentCart.addToCurrentCart()` properties, learn more about [integrating Wix Stores with the Wix eCommerce](https://dev.wix.com/docs/velo/api-reference/wix-stores-backend/e-commerce-integration). * > * > 3. Test your changes to make sure your code behaves as expected. * * Adds one or more products to the cart. * * The `addProducts()` function returns a Promise that is resolved when the * specified products are added to the cart. * * Use the `quantity` property of each `AddToCartItem` object that is * passed to the products parameter to add one or more products to the cart at one time. * * Use the `options` property of each `AddToCartItem` object that is * passed to the products parameter to specify the product options to choose when adding * the product to the cart. For example, if a product comes in different sizes, you can * specify the size that should be added to the cart. If the product you are adding to the * cart has options, you must specify which options should be chosen. * * You can see a product's option information in the `productOptions` field in the **Stores/Products** collection. * * You can use [`product.getOptionsAvailability()`](https://www.wix.com/velo/reference/wix-stores-frontend/product/getoptionsavailability) * to determine if an item with specific options is available for purchase. * * > **Note:** If you use [`wix-stores-backend.createProduct()`](https://www.wix.com/velo/reference/wix-stores-backend/createproduct) immediately before adding that product to the cart, we suggest [setting a timeout](https://developer.mozilla.org/en-US/docs/Web/API/setTimeout) for `"1000"` milliseconds (1 second) before calling `cart.addProducts()`. While this slows down the operation slightly, it also ensures proper retrieval of the newly created product before adding it to the cart. * @param products - One or more products to be added to the cart. * @requiredField products * @servicePath wix-stores-frontend.Cart.AddToCartItem * @returns Fulfilled - The updated cart with added products. * @servicePath wix-stores-frontend.CartObj */ declare function addProducts(products: AddToCartItem[]): Promise; /** * **Deprecated.** * This function will continue to work, but a newer version is available at * [`wix-ecom-backend.currentCart.updateCurrentCart()`](https://dev.wix.com/docs/velo/api-reference/wix-ecom-backend/current-cart/update-current-cart). * * > #### Migration Instructions * > * > If this function is already in your code, it will continue to work. * > To stay compatible with future changes, migrate to * > [`wix-ecom-backend.currentCart.updateCurrentCart()`](https://dev.wix.com/docs/velo/api-reference/wix-ecom-backend/current-cart/update-current-cart). * > * > To migrate to the new function: * > * > 1. Add the new import statement: * > * > ```javascript * > import { currentCart } from "wix-ecom-backend"; * > ``` * > * > 2. Look for any code that uses `cart.applyCoupon()`, * > and replace it with `currentCart.updateCurrentCart()`. * > Update your code to work with the new `currentCart.updateCurrentCart()` * > call and response properties. * > * > 3. Test your changes to make sure your code behaves as expected. * * Adds and applies a coupon to the cart. * * The `applyCoupon()` function returns a Promise that resolves to the current * site visitor's cart when the specified coupon has been applied. * * The cart can only hold one coupon. If a coupon is already applied to the cart, passing a different `couponCode` to `applyCoupon()` will replace the existing one. * * > **Note:** When [editing a site as a contributor](https://support.wix.com/en/article/velo-working-with-contributors), `applyCoupon()` will only work when viewing the live site. * @param couponCode - The code of the coupon to be applied to the cart. * @requiredField couponCode * @returns Fulfilled - The updated cart. * @servicePath wix-stores-frontend.CartObj */ declare function applyCoupon(couponCode: string): Promise; /** * **Deprecated.** * This function will continue to work, but a newer version is available at * [`wix-ecom-backend.CurrentCart.getCurrentCart()`](https://www.wix.com/velo/reference/wix-ecom-backend/currentcart/getcurrentcart). * * We recommend you migrate to the new [Wix eCommerce APIs](https://www.wix.com/velo/reference/wix-ecom-backend/introduction) as soon as possible. * * > #### Migration Instructions * > * > If this function is already in your code, it will continue to work. * > To stay compatible with future changes, migrate to * > [`wix-ecom-backend.CurrentCart.getCurrentCart()`](https://dev.wix.com/docs/velo/api-reference/wix-ecom-backend/currentcart/getcurrentcart). * > * > The `wix-ecom-backend.CurrentCart.getCurrentCart()` function works from both backend and frontend code. * > * > To migrate to the new function: * > * > 1. Add the new import statement: * > * > ```javascript * > import { currentCart } from 'wix-ecom-backend'; * > ``` * > * > 2. Look for any code that uses `cart.getCurrentCart()`, * > and replace it with `currentCart.getCurrentCart()`. * > Update your code to work with the new `currentCart.getCurrentCart()` * > call and response properties. * > For more info about the differences between the Stores Cart and eCommerce Cart, refer to the [cart conversion table](https://www.wix.com/velo/reference/wix-ecom-backend/cart/stores-to-ecommerce-cart-conversion-table). * > * > 3. Test your changes to make sure your code behaves as expected. * * Gets the current site visitor's shopping cart. * * The `getCurrentCart()` function returns a Promise that resolves to the current * site visitor's shopping cart. * * @returns Fulfilled - The retrieved cart. * @servicePath wix-stores-frontend.CartObj */ declare function getCurrentCart(): Promise; /** * **Deprecated.** * This function will continue to work, but will soon be deprecated. Hiding the Mini Cart or Side Cart can be done by clicking anywhere else on the page. * * Hides the Mini Cart. * * The `hideMiniCart()` function hides the Mini Cart. * Learn more about the [Mini Cart](https://support.wix.com/en/article/customizing-the-cart-page). * * > **Note:** This API will fail when viewing the site on mobile because there is no Mini Cart on the mobile site. */ declare function hideMiniCart(): Promise; /** * **Deprecated.** * This function will continue to work, but a newer version is available at * [`wix-ecom-frontend.onCartChange()`](https://dev.wix.com/docs/velo/api-reference/wix-ecom-frontend/on-cart-change). * * > #### Migration Instructions * > * > If this function is already in your code, it will continue to work. * > To stay compatible with future changes, migrate to * > [`wix-ecom-frontend.onCartChange()`](https://dev.wix.com/docs/velo/api-reference/wix-ecom-frontend/on-cart-change). * > * > To migrate to the new function: * > * > 1. Add the new import statement: * > * > ```javascript * > import wixEcomFrontend from "wix-ecom-frontend"; * > ``` * > * > 2. Look for any code that uses `cart.onChange()`, * > and replace it with `wixEcomFrontend.onCartChange()`. * > The new `onCartChange()` event handler does not return the changed cart. Update your code accordingly. * > * > 3. Test your changes to make sure your code behaves as expected. * * * An event handler that is triggered when items are added or removed from a cart. * * The `onChange()` function is a client-side event handler invoked every time the cart changes. It takes a callback function which receives the new `Cart` object as a parameter. * * > **Notes:** * > + Use `onChange()` in the global site code file (masterPage.js). This ensures the event is triggered when a change to the cart is made on any page. Learn more about [global (site) code](https://support.wix.com/en/article/velo-working-with-the-velo-sidebar#global-site). * > + The `onChange()` function can only be used once a page has loaded. Therefore, you must use it in code that is contained in or is called from the [onReady()](https://dev.wix.com/docs/velo/api-reference/$w/on-ready) event handler or any element event handler. * > + When [editing a site as a contributor](https://support.wix.com/en/article/velo-working-with-contributors), `onChange()` will only work when viewing the live site. * @param handler - The name of the function to run when a cart changes. * @requiredField handler * @servicePath wix-stores-frontend.CartChangedHandler */ declare function onChange(handler: CartChangedHandler): Promise; /** * **Deprecated.** * This function will continue to work, but a newer version is available at * [`wix-ecom-backend.currentCart.removeCouponFromCurrentCart()`](https://dev.wix.com/docs/velo/api-reference/wix-ecom-backend/current-cart/remove-coupon-from-current-cart). * * > #### Migration Instructions * > * > If this function is already in your code, it will continue to work. * > To stay compatible with future changes, migrate to * > [`wix-ecom-backend.currentCart.removeCouponFromCurrentCart()`](https://dev.wix.com/docs/velo/api-reference/wix-ecom-backend/current-cart/remove-coupon-from-current-cart). * > * > To migrate to the new function: * > * > 1. Add the new import statement: * > * > ```javascript * > import { currentCart } from "wix-ecom-backend"; * > ``` * > * > 2. Look for any code that uses `cart.removeCoupon()`, * > and replace it with `currentCart.removeCouponFromCurrentCart()`. * > Update your code to work with the new `currentCart.removeCouponFromCurrentCart()` * > call and response properties. * > * > 3. Test your changes to make sure your code behaves as expected. * * Removes the coupon currently applied to the cart. * * The `removeCoupon()` function returns a Promise that resolves to the current * site visitor's cart when the currently applied coupon has been removed. * * > **Note:** When [editing a site as a contributor](https://support.wix.com/en/article/velo-working-with-contributors), `removeCoupon()` will only work when viewing the live site. * * @returns Fulfilled - The updated cart. * @servicePath wix-stores-frontend.CartObj */ declare function removeCoupon(): Promise; /** * **Deprecated.** * This function will continue to work, but a newer version is available at * [`wix-ecom-backend.currentCart.removeLineItemsFromCurrentCart()`](https://dev.wix.com/docs/velo/api-reference/wix-ecom-backend/current-cart/remove-line-items-from-current-cart). * * > #### Migration Instructions * > * > If this function is already in your code, it will continue to work. * > To stay compatible with future changes, migrate to * > [`wix-ecom-backend.currentCart.removeLineItemsFromCurrentCart()`](https://dev.wix.com/docs/velo/api-reference/wix-ecom-backend/current-cart/remove-line-items-from-current-cart). * > * > To migrate to the new function: * > * > 1. Add the new import statement: * > * > ```javascript * > import { currentCart } from "wix-ecom-backend"; * > ``` * > * > 2. Look for any code that uses `cart.removeProduct()`, * > and replace it with `currentCart.removeLineItemsFromCurrentCart()`. * > Update your code to work with the new `currentCart.removeLineItemsFromCurrentCart()` * > call and response properties. * > * > 3. Test your changes to make sure your code behaves as expected. * * Removes a specified product from the cart. * * The `removeProduct()` function returns a Promise that resolves to the * updated cart after the product is removed. * Every line item in a cart has an ID. Pass this to `removeProduct()` to remove that line item/product from the cart. * * > **Notes:** * > + `removeProduct()` does not decrement the line item's quantity, it removes the line item/product altogether. * > + When [editing a site as a contributor](https://support.wix.com/en/article/velo-working-with-contributors), `removeProduct()` will only work when viewing the live site. * @param cartLineItemId - ID of the cart line item to remove. * @requiredField cartLineItemId * @returns Fulfilled - The updated cart. * @servicePath wix-stores-frontend.CartObj */ declare function removeProduct(cartLineItemId: number): Promise; /** * **Deprecated.** * This function will continue to work, but a newer version is available at * [`wix-ecom-frontend.openSideCart()`](https://dev.wix.com/docs/velo/api-reference/wix-ecom-frontend/open-side-cart). * * > #### Migration Instructions * > * > If this function is already in your code, it will continue to work. * > To stay compatible with future changes, migrate to * > [`wix-ecom-frontend.openSideCart()`](https://dev.wix.com/docs/velo/api-reference/wix-ecom-frontend/open-side-cart). * > * > To migrate to the new function: * > * > 1. Add the new import statement: * > * > ```javascript * > import wixEcomFrontend from "wix-ecom-frontend"; * > ``` * > * > 2. Look for any code that uses `cart.showMiniCart()`, * > and replace it with `wixEcomFrontend.openSideCart()`. * > * > 3. Test your changes to make sure your code behaves as expected. * * Shows the Mini Cart. * * The `showMiniCart()` function displays the Mini Cart. * Learn more about the [Mini Cart](https://support.wix.com/en/article/customizing-the-cart-page). * > **Note:** This API will fail when viewing the site on mobile because there is no Mini Cart on the mobile site. */ declare function showMiniCart(): Promise; /** * **Deprecated.** * This function will continue to work, but a newer version is available at * [`wix-ecom-backend.currentCart.updateCurrentCartLineItemQuantity()`](https://dev.wix.com/docs/velo/api-reference/wix-ecom-backend/current-cart/update-current-cart-line-item-quantity). * * > #### Migration Instructions * > * > If this function is already in your code, it will continue to work. * > To stay compatible with future changes, migrate to * > [`wix-ecom-backend.currentCart.updateCurrentCartLineItemQuantity()`](https://dev.wix.com/docs/velo/api-reference/wix-ecom-backend/current-cart/update-current-cart-line-item-quantity). * > * > To migrate to the new function: * > * > 1. Add the new import statement: * > * > ```javascript * > import { currentCart } from "wix-ecom-backend"; * > ``` * > * > 2. Look for any code that uses `cart.updateLineItemQuantity()`, * > and replace it with `currentCart.updateCurrentCartLineItemQuantity()`. * > Update your code to work with the new `currentCart.updateCurrentCartLineItemQuantity()` * > call and response properties. * * Updates the quantity of a specified line item in the cart. * * The `updateLineItemQuantity()` function returns a Promise that resolves to the current * site visitor's cart when the specified line item's quantity has been updated. * * > **Note:** When [editing a site as a contributor](https://support.wix.com/en/article/velo-working-with-contributors), `updateLineItemQuantity()` will only work when viewing the live site. * @param cartLineItemId - ID of the cart line item to update. * @requiredField cartLineItemId * @param quantity - Line item's new quantity. * @requiredField quantity * @returns Fulfilled - The updated cart. * @servicePath wix-stores-frontend.CartObj */ declare function updateLineItemQuantity(cartLineItemId: number, quantity: number): Promise; type cartSdkModuleRuntime_AddToCartItem = AddToCartItem; type cartSdkModuleRuntime_AddToCartOptions = AddToCartOptions; type cartSdkModuleRuntime_Cart = Cart; type cartSdkModuleRuntime_CustomTextField = CustomTextField; declare const cartSdkModuleRuntime_addProducts: typeof addProducts; declare const cartSdkModuleRuntime_applyCoupon: typeof applyCoupon; declare const cartSdkModuleRuntime_getCurrentCart: typeof getCurrentCart; declare const cartSdkModuleRuntime_hideMiniCart: typeof hideMiniCart; declare const cartSdkModuleRuntime_onChange: typeof onChange; declare const cartSdkModuleRuntime_removeCoupon: typeof removeCoupon; declare const cartSdkModuleRuntime_removeProduct: typeof removeProduct; declare const cartSdkModuleRuntime_showMiniCart: typeof showMiniCart; declare const cartSdkModuleRuntime_updateLineItemQuantity: typeof updateLineItemQuantity; declare namespace cartSdkModuleRuntime { export { type cartSdkModuleRuntime_AddToCartItem as AddToCartItem, type cartSdkModuleRuntime_AddToCartOptions as AddToCartOptions, type cartSdkModuleRuntime_Cart as Cart, type cartSdkModuleRuntime_CustomTextField as CustomTextField, cartSdkModuleRuntime_addProducts as addProducts, cartSdkModuleRuntime_applyCoupon as applyCoupon, cartSdkModuleRuntime_getCurrentCart as getCurrentCart, cartSdkModuleRuntime_hideMiniCart as hideMiniCart, cartSdkModuleRuntime_onChange as onChange, cartSdkModuleRuntime_removeCoupon as removeCoupon, cartSdkModuleRuntime_removeProduct as removeProduct, cartSdkModuleRuntime_showMiniCart as showMiniCart, cartSdkModuleRuntime_updateLineItemQuantity as updateLineItemQuantity }; } type Methods$2 = { [P in keyof T as T[P] extends Function ? P : never]: T[P]; }; declare const cartRuntime: MaybeContext, Host> & Methods$2>; /** * The wix-stores-frontend.Navigate module contains functionality for navigating to * store-related pages from frontend code. * * To use the Wix Stores Navigate API, import `{ navigate }` from the `wix-stores-frontend` module: * * ```javascript * import { navigate } from 'wix-stores-frontend'; * ``` */ interface Navigate { /** * **Deprecated.** * This function will continue to work, but a newer version is available at * [`wix-ecom-frontend.navigateToCartPage()`](https://dev.wix.com/docs/velo/api-reference/wix-ecom-frontend/navigate-to-cart-page). * * > #### Migration Instructions * > * > If this function is already in your code, it will continue to work. * > To stay compatible with future changes, migrate to * > [`wix-ecom-frontend.navigateToCartPage()`](https://dev.wix.com/docs/velo/api-reference/wix-ecom-frontend/navigate-to-cart-page). * > * > To migrate to the new function: * > * > 1. Add the new import statement: * > * > ```javascript * > import wixEcomFrontend from "wix-ecom-frontend"; * > ``` * > * > 2. Look for any code that uses `navigate.toCart()`, * > and replace it with `wixEcomFrontend.navigateToCartPage()`. * > * > 3. Test your changes to make sure your code behaves as expected. * * Directs the browser to navigate to the site visitor's cart page. * * The `toCart()` function navigates the browser to the site visitor's cart page. * * @returns Fulfilled - When the browser is directed to the site visitor's cart page. */ toCart(): Promise; /** * Navigates to the specified product's page. * * ![developer preview tag](https://user-images.githubusercontent.com/89579857/213133550-2b4fa3e8-e8fc-4513-a733-00abcc70925c.png) * * > **Note:** This method is supported in [sites](https://dev.wix.com/docs/develop-websites) and [mobile apps](https://www.wix.com/app-builder). * @param productId - ID of the product to navigate to. * @requiredField productId * @returns Fulfilled - When the browser or app is directed to the product's page. */ toProduct(productId: string): Promise; } /** * **Deprecated.** * This function will continue to work, but a newer version is available at * [`wix-ecom-frontend.navigateToCartPage()`](https://dev.wix.com/docs/velo/api-reference/wix-ecom-frontend/navigate-to-cart-page). * * > #### Migration Instructions * > * > If this function is already in your code, it will continue to work. * > To stay compatible with future changes, migrate to * > [`wix-ecom-frontend.navigateToCartPage()`](https://dev.wix.com/docs/velo/api-reference/wix-ecom-frontend/navigate-to-cart-page). * > * > To migrate to the new function: * > * > 1. Add the new import statement: * > * > ```javascript * > import wixEcomFrontend from "wix-ecom-frontend"; * > ``` * > * > 2. Look for any code that uses `navigate.toCart()`, * > and replace it with `wixEcomFrontend.navigateToCartPage()`. * > * > 3. Test your changes to make sure your code behaves as expected. * * Directs the browser to navigate to the site visitor's cart page. * * The `toCart()` function navigates the browser to the site visitor's cart page. * * @returns Fulfilled - When the browser is directed to the site visitor's cart page. */ declare function toCart(): Promise; /** * Navigates to the specified product's page. * * ![developer preview tag](https://user-images.githubusercontent.com/89579857/213133550-2b4fa3e8-e8fc-4513-a733-00abcc70925c.png) * * > **Note:** This method is supported in [sites](https://dev.wix.com/docs/develop-websites) and [mobile apps](https://www.wix.com/app-builder). * @param productId - ID of the product to navigate to. * @requiredField productId * @returns Fulfilled - When the browser or app is directed to the product's page. */ declare function toProduct(productId: string): Promise; type navigateSdkModuleRuntime_Navigate = Navigate; declare const navigateSdkModuleRuntime_toCart: typeof toCart; declare const navigateSdkModuleRuntime_toProduct: typeof toProduct; declare namespace navigateSdkModuleRuntime { export { type navigateSdkModuleRuntime_Navigate as Navigate, navigateSdkModuleRuntime_toCart as toCart, navigateSdkModuleRuntime_toProduct as toProduct }; } type Methods$1 = { [P in keyof T as T[P] extends Function ? P : never]: T[P]; }; declare const navigateRuntime: MaybeContext, Host> & Methods$1>; /** * The wix-stores-frontend.product module contains functionality for working with a * store's products from frontend code. * * To use the Wix Stores Product API, import `{ product }` from the `wix-stores-frontend` module: * * ```javascript * import { product } from 'wix-stores-frontend'; * ``` */ interface Product { /** * Retrieves the availability of a product based on the specified option choices. * * The information returned in the `selectedVariant` and `availableForPurchase` * properties reflects the option choices passed in the `choices` parameter. * * If the specified choices result in the selection of a single product variant, * that variant is returned in the `selectedVariant` property and the `availableForPurchase` * property indicates whether that product variant is available for purchase. * * If the choices specified in the `choices` parameter don't result in the selection of a single product variant, * no variant is returned in the `selectedVariant` property and the `availableForPurchase` * property will be `false`. * @param productId - The ID of the product whose availability is being checked. * @requiredField productId * @param choices - Option choices to use when checking the product's availability in the form of * an object containing a `key:value` pair for each product option. For example, if a product has a size option, the key will be something like "Size" and its value will be something like "Large". * @requiredField choices * @returns Fulfilled - The availability information of the product. * @servicePath wix-stores-frontend.ProductOptionsAvailability */ getOptionsAvailability(productId: string, choices: object): Promise; /** * Gets a product's available variants based on the specified product ID and either option choices or variant IDs. * @param productId - ID of the product whose variants are being retrieved. Pass only this field to retrieve all of the specified product's variants. * @requiredField productId * @param options - Variant options to return. If not specified, all the product's variants are returned. * @servicePath wix-stores-frontend.ProductVariantOptions * @returns Fulfilled - The variants with the specified choices. * @servicePath wix-stores-frontend.VariantItem */ getVariants(productId: string, options?: ProductVariantOptions): Promise; /** * Opens the [Quick View](https://support.wix.com/en/article/wix-stores-customizing-the-quick-view-in-the-product-gallery) modal of a specified product. * * The quantity input field in the Quick View will be pre-populated with 1, unless otherwise specified in the `options.quantity` field. * * If the product has different [options or variants](https://support.wix.com/en/article/wix-stores-adding-and-customizing-product-options#product-option-faqs), * they will be displayed for selection in the opened Quick View. * * >**Note:** * > This API fails when viewing the site on mobile because there is no Quick View on the mobile site. * @param productId - ID of the product to be displayed in the Quick View. * @requiredField productId * @param options - Quick View options. * @servicePath wix-stores-frontend.QuickViewOptions * @returns Fulfilled - When the Quick View modal is opened. */ openQuickView(productId: string, options?: QuickViewOptions): Promise; } /** * Retrieves the availability of a product based on the specified option choices. * * The information returned in the `selectedVariant` and `availableForPurchase` * properties reflects the option choices passed in the `choices` parameter. * * If the specified choices result in the selection of a single product variant, * that variant is returned in the `selectedVariant` property and the `availableForPurchase` * property indicates whether that product variant is available for purchase. * * If the choices specified in the `choices` parameter don't result in the selection of a single product variant, * no variant is returned in the `selectedVariant` property and the `availableForPurchase` * property will be `false`. * @param productId - The ID of the product whose availability is being checked. * @requiredField productId * @param choices - Option choices to use when checking the product's availability in the form of * an object containing a `key:value` pair for each product option. For example, if a product has a size option, the key will be something like "Size" and its value will be something like "Large". * @requiredField choices * @returns Fulfilled - The availability information of the product. * @servicePath wix-stores-frontend.ProductOptionsAvailability */ declare function getOptionsAvailability(productId: string, choices: object): Promise; /** * Gets a product's available variants based on the specified product ID and either option choices or variant IDs. * @param productId - ID of the product whose variants are being retrieved. Pass only this field to retrieve all of the specified product's variants. * @requiredField productId * @param options - Variant options to return. If not specified, all the product's variants are returned. * @servicePath wix-stores-frontend.ProductVariantOptions * @returns Fulfilled - The variants with the specified choices. * @servicePath wix-stores-frontend.VariantItem */ declare function getVariants(productId: string, options?: ProductVariantOptions): Promise; /** * Opens the [Quick View](https://support.wix.com/en/article/wix-stores-customizing-the-quick-view-in-the-product-gallery) modal of a specified product. * * The quantity input field in the Quick View will be pre-populated with 1, unless otherwise specified in the `options.quantity` field. * * If the product has different [options or variants](https://support.wix.com/en/article/wix-stores-adding-and-customizing-product-options#product-option-faqs), * they will be displayed for selection in the opened Quick View. * * >**Note:** * > This API fails when viewing the site on mobile because there is no Quick View on the mobile site. * @param productId - ID of the product to be displayed in the Quick View. * @requiredField productId * @param options - Quick View options. * @servicePath wix-stores-frontend.QuickViewOptions * @returns Fulfilled - When the Quick View modal is opened. */ declare function openQuickView(productId: string, options?: QuickViewOptions): Promise; type productSdkModuleRuntime_Product = Product; declare const productSdkModuleRuntime_getOptionsAvailability: typeof getOptionsAvailability; declare const productSdkModuleRuntime_getVariants: typeof getVariants; declare const productSdkModuleRuntime_openQuickView: typeof openQuickView; declare namespace productSdkModuleRuntime { export { type productSdkModuleRuntime_Product as Product, productSdkModuleRuntime_getOptionsAvailability as getOptionsAvailability, productSdkModuleRuntime_getVariants as getVariants, productSdkModuleRuntime_openQuickView as openQuickView }; } type Methods = { [P in keyof T as T[P] extends Function ? P : never]: T[P]; }; declare const productRuntime: MaybeContext, Host> & Methods>; export { cartRuntime as cart, navigateRuntime as navigate, productRuntime as product };