Skip to content

CommerceClient

Describes@ebitex/commerce-sdk 0.2.xSee the changelog:@ebitex/commerce-sdk

cart(id, options): Promise<Cart | null>

The cart with every price and total worked out now, or null when it is not this shopper’s or does not exist. throwIfMissing makes that an error.

string

CartCallOptions & object

Promise<Cart | null>


categories(options?): Promise<CategoryList>

The categories the store’s products use.

CallOptions

Promise<CategoryList>


createCart(input, options): Promise<Cart>

Creates an empty cart for the shopper. Its currency (one the store sells in) is fixed for its life.

CreateCartInput | undefined

CartCallOptions

Promise<Cart>


deleteCart(id, options): Promise<void>

Deletes the cart.

string

CartCallOptions

Promise<void>


eachPage<A>(query?, options?): AsyncGenerator<ProductsPage<A>, void, undefined>

Every page of a query as an async iterator. The query is captured once and replayed unchanged for each page.

A = Record<string, unknown>

Omit<ProductsQuery, "cursor">

CallOptions

AsyncGenerator<ProductsPage<A>, void, undefined>


eachProduct<A>(query?, options?): AsyncGenerator<Product<A>, void, undefined>

Every product a query matches, one at a time.

A = Record<string, unknown>

Omit<ProductsQuery, "cursor">

CallOptions

AsyncGenerator<Product<A>, void, undefined>


product<A>(key, options?): Promise<Product<A> | null>

One product, or null when there is none available to this key. throwIfMissing makes that an error.

A = Record<string, unknown>

string

CallOptions & object

Promise<Product<A> | null>


productResponse<A>(key, options?): Promise<ProductResponse<A>>

The primitive under product: keeps the ETag, and sends If-None-Match when given, so an unchanged product is notModified.

A = Record<string, unknown>

string

CallOptions & object

Promise<ProductResponse<A>>


products<A>(query?, options?): Promise<ProductsPage<A>>

One page of products.

A = Record<string, unknown>

ProductsQuery

CallOptions

Promise<ProductsPage<A>>


productsByKeys<A>(keys, options?): Promise<ProductBatch<A>>

Up to 50 products by key in one round trip, in the order asked; the keys that are not available are in missing.

A = Record<string, unknown>

readonly string[]

CallOptions

Promise<ProductBatch<A>>


setCartAddress(id, addresses, options): Promise<Cart>

Sets the delivery and/or billing address: present replaces (null clears), absent is left alone. Returns the whole cart.

string

SetAddressInput

CartCallOptions

Promise<Cart>


setCartLine(id, sku, quantity, options): Promise<Cart>

Sets one SKU’s quantity: 1 to 99 adds or changes the line, 0 removes it. Returns the whole cart.

string

string

number

CartCallOptions

Promise<Cart>


setCartPromotionCodes(id, codes, options): Promise<Cart>

Replaces the cart’s promotion codes. They are recorded and change no price in this release. Returns the whole cart.

string

readonly string[]

CartCallOptions

Promise<Cart>


startCheckout(id, input, options): Promise<CheckoutStarted>

Starts paying for the cart: it becomes an order awaiting payment, its stock is held for the payment window (not in test mode), and the answer carries the payment provider’s page to send the shopper to. The server prices the cart afresh, so the shopper pays what the cart shows now. A cart can start a checkout only a few times a minute.

string

CheckoutInput

CartCallOptions

Promise<CheckoutStarted>


stock(skus, options?): Promise<StockResult>

Live stock for up to 50 SKUs: never cached, so it is the authority a checkout confirms against (the product reads’ availability is for display, up to a few minutes old). Counts appear only when the key may see them; see StockItem.available. Budgeted tighter than the other reads, so call it when you need it, not on every render.

readonly string[]

CallOptions

Promise<StockResult>


store(options?): Promise<StoreInfo>

The store this key reads: its key, name, currency and whether its prices include tax.

CallOptions

Promise<StoreInfo>