Skip to main content

CartIntegration

Overview​

This represents the set of operations available when initializing an integration with the Cart function exported by this package. It provides a set of functions to interact with the cart and its related entities in a reasonably vendor-agnostic way. The input parameters and results will vary based on the CartModes.

note

The full set of operations available will depend on the commerce vendor. For ex. a vendor may not support the concept of addPaymentToCart, in which case the function won't be implemented.

Shipping & payment related functions won't be called at all if using a hosted checkout outside the High Velocity front-end app.

VendorCartIntegration​

Cart Integration function as exported by Vendor packages. Extends CartIntegration, adding attributes specifying the CartModes for the integration.

For ex. with Shopify as the cart provider, which returns expanded product line items and manages line item pricing internally:

export function Cart(...) {
return {
lineItemPricing: 'internal',
lineItemType: 'expanded',

async addToCart(...) { ... },
...
}
}

Functions​

addPaymentToCart​

Add a payment to the cart with the given parameters.

Parameters​

params

type: AddPaymentToCartParams

The parameters required to add the payment to the cart.

Return Value​

type: Promise<Result<Cart<TCartModes>>>

A promise that resolves to the result of the cart with the added payment.

addPromoCode​

Add a promotional code to the cart with the given parameters.

Parameters​

params

type: AddPromoCodeParams

The parameters required to add the promotional code to the cart.

Return Value​

type: Promise<Result<Cart<TCartModes>>>

A promise that resolves to the result of the cart with the added promotional code.

addToCart​

Add an item to the cart with the given parameters.

Parameters​

params

type: AddToCartParams<TCartModes['lineItemPricing']>

The parameters required to add the item to the cart.

Return Value​

type: Promise<Result<Cart<TCartModes>>>

A promise that resolves to the result of the cart with the added item.

createCart​

Create a new cart with the given draft and payload.

Parameters​

draft

type: Partial<CartDraft>

A partial draft of the cart to be created.

payload

type: AddToCartParams<TCartModes['lineItemPricing']>['payload']

The payload containing additional parameters for creating the cart.

Return Value​

type: Promise<Result<Cart<TCartModes>>>

A promise that resolves to the result of the created cart.

createPayment​

Create a payment with the given parameters.

Parameters​

params

type: CreatePaymentParams

The parameters required to create the payment.

Return Value​

type: Promise<Result<Payment>>

A promise that resolves to the result of the created payment.

getCart​

Get a cart by its ID.

Parameters​

cartID

type: string

The unique identifier for the cart.

Return Value​

type: Promise<Result<Cart<TCartModes>>

A promise that resolves to the result of the cart.

getCustomerCart​

Get a cart by the customer ID.

Parameters​

customerID

type: string

The unique identifier for the customer.

Return Value​

type: Promise<Result<Cart<TCartModes> | null>>

A promise that resolves to the result of the cart or null if no cart is found.

getOrder​

Retrieve an order by its ID.

Parameters​

orderID

type: string

The unique identifier for the order.

Return Value​

type: Promise<Result<Order<TCartModes>>>

A promise that resolves to the result of the retrieved order.

getPayment​

Get a payment by its ID.

Parameters​

id

type: string

The unique identifier for the payment.

Return Value​

type: Promise<Result<Payment>>

A promise that resolves to the result of the payment.

getPaymentMethods​

Retrieve the available payment methods for the cart.

Parameters​

None

Return Value​

type: Promise<Result<PaymentMethod[]>>

A promise that resolves to the result of the available payment methods.

getShippingMethods​

Retrieve the available shipping methods for the cart with the given parameters.

Parameters​

params

type: GetShippingMethodParams

The parameters required to get the shipping methods.

Return Value​

type: Promise<Result<CartShippingMethod[]>>

A promise that resolves to the result of the available shipping methods.

placeOrder​

Place an order with the given parameters.

Parameters​

params

type: PlaceOrderParams

The parameters required to place the order.

Return Value​

type: Promise<Result<Order<TCartModes>>>

A promise that resolves to the result of the placed order.

removeFromCart​

Remove an item from the cart with the given parameters.

Parameters​

params

type: RemoveFromCartParams

The parameters required to remove the item from the cart.

Return Value​

type: Promise<Result<Cart<TCartModes>>>

A promise that resolves to the result of the cart with the item removed.

removePromoCode​

Remove a promotional code from the cart with the given parameters.

Parameters​

params

type: RemovePromoCodeParams

The parameters required to remove the promotional code from the cart.

Return Value​

type: Promise<Result<Cart<TCartModes>>>

A promise that resolves to the result of the cart with the promotional code removed.

updateCart​

Update the cart with the given parameters.

Parameters​

params

type: UpdateCartParams

The parameters required to update the cart.

Return Value​

type: Promise<Result<Cart<TCartModes>>>

A promise that resolves to the result of the updated cart.

updateLineItem​

Update a line item in the cart with the given parameters.

Parameters​

params

type: UpdateLineItemParams<TCartModes['lineItemPricing']>

The parameters required to update the line item.

Return Value​

type: Promise<Result<Cart<TCartModes>>

A promise that resolves to the result of the updated cart.

updateOrder​

Update an order with the given parameters.

Parameters​

params

type: UpdateOrderParams

The parameters required to update the order.

Return Value​

type: Promise<Result<Order<TCartModes>>>

A promise that resolves to the result of the updated order.