Skip to main content

CartRepositoryInterface

Interface for cart repository implementations. Defines methods for interacting with the cart API.

Methods​

addToCart()​

addToCart(params): Promise<{ cart: { discount_codes: object[]; items: object[]; token: string; }; sections?: Record<string, string | null>; }>

Adds items to the cart.

Parameters​

ParameterTypeDescription
params{ items: object[]; sections?: string[]; }Parameters for adding items
params.itemsobject[]Array of items to add
params.sections?string[]Optional sections to return in response

Returns​

Promise<{ cart: { discount_codes: object[]; items: object[]; token: string; }; sections?: Record<string, string | null>; }>

Promise with updated cart and optional sections


changeCartItem()​

changeCartItem(params): Promise<{ cart: { discount_codes: object[]; items: object[]; token: string; }; sections?: Record<string, string | null>; }>

Updates the cart with discount codes, attributes, or other modifications.

Parameters​

ParameterTypeDescription
params{ lineKey?: string; quantity: number; sections?: string[]; variantID: number; }Update parameters
params.lineKey?stringAjax cart line key, when the caller knows which line to change.
params.quantitynumber-
params.sections?string[]Sections to return in response
params.variantIDnumber-

Returns​

Promise<{ cart: { discount_codes: object[]; items: object[]; token: string; }; sections?: Record<string, string | null>; }>

Promise with updated cart data


getCart()​

getCart(): Promise<{ cart: { discount_codes: object[]; items: object[]; token: string; }; }>

Retrieves the current cart.

Returns​

Promise<{ cart: { discount_codes: object[]; items: object[]; token: string; }; }>

Promise with cart data


updateCart()​

updateCart(params): Promise<{ discount_codes: object[]; items: object[]; sections: Record<string, string | null>; token: string; }>

Parameters​

ParameterType
params{ attributes?: Record<string, string>; discount?: string; sections: string[]; }
params.attributes?Record<string, string>
params.discount?string
params.sectionsstring[]

Returns​

Promise<{ discount_codes: object[]; items: object[]; sections: Record<string, string | null>; token: string; }>