Interfaces

Interface: UseCart

react-autonomy.UseCart

UseCart contains the data and methods returned by the useCart hook.

Hierarchy

  • Omit<RootInitialState["cart"], "data">

Properties

addCrossSell

addCrossSell: (options: CrossSell) => Promise<OrderBig>

Type declaration

▸ (options): Promise<OrderBig>

The addCrossSell function takes an array of line items post-checkout and adds them to the order, charging the card again in the process.



JS


Parameters

Name

Type

options

CrossSell

Returns

Promise<OrderBig>

Defined in



addPromoCode

addPromoCode: (options: AddPromoCode) => Promise<OrderBig>

Type declaration

▸ (options): Promise<OrderBig>

The addPromoCode function applies a promo code to the current shopping cart.



JS


Parameters

Name

Type

options

AddPromoCode

Returns

Promise<OrderBig>

Defined in



addSubscription

addSubscription: (subscription: AddSubscriptionItem) => Promise<OrderBig>

Type declaration

▸ (subscription): Promise<OrderBig>

The addSubscription function adds a subscription item to the customer's cart.



JS


Parameters

Name

Type

subscription

Returns

Promise<OrderBig>

Defined in



addToCart

addToCart: (items: AddToCartItem | AddToCartItem[]) => Promise<OrderBig>

Type declaration

▸ (items): Promise<OrderBig>

The addToCart function adds a product variant to the current shopping cart (creating a line item).



JS


Parameters

Name

Type

Description

items

The items to add to the cart.

Returns

Promise<OrderBig>

A Promise that resolves once the items are added to the cart.

Defined in



cart

cart: Partial<OrderBig>

An object representing the current shopping cart.

Defined in



checkRedemptionCodeValidity

checkRedemptionCodeValidity: (code: string, email: string) => Promise<OrderBig>

Type declaration

▸ (code, email): Promise<OrderBig>

The checkRedemptionCodeValidity function checks the validity of a gift card redemption code or prepaid subscription redemption code. It does not require the customer to be logged in. It will return the order the redemption code is valid for such that a redemption code form can be filled in or products can be displayed dynamically.



JS


Parameters

Name

Type

code

string

email

string

Returns

Promise<OrderBig>

A Promise that resolves with the order the redemption code is valid for.

Defined in



emptyCart

emptyCart: () => Promise<OrderBig>

Type declaration

▸ (): Promise<OrderBig>

The emptyCart function clears the customer's cart contents (line items, promo codes, metadata) while keeping the same order number.

Returns

Promise<OrderBig>

Defined in



error

error: Error

Inherited from

Omit.error

Defined in



forgetCart

forgetCart: () => { type: string = FORGET_CART }

Type declaration

▸ (): Object

The forgetCart function clears the customer's cart.

Returns

Object

Name

Type

type

string

Defined in



isFetching

isFetching: boolean

Inherited from

Omit.isFetching

Defined in



isLoaded

isLoaded: boolean

Inherited from

Omit.isLoaded

Defined in



loadCart

loadCart: () => Promise<OrderBig>

Type declaration

▸ (): Promise<OrderBig>

The loadCart function loads the current cart based on the current browser session and populates the cart in Redux. loadCart is automatically called on page load so this should not be called except in exceptional circumstances.



JS


Returns

Promise<OrderBig>

A Promise that resolves when the cart object has been added to Redux.

Defined in



modifyCart

modifyCart: (options: ModifyCart) => Promise<OrderBig>

Type declaration

▸ (options): Promise<OrderBig>

The modifyCart function modifies the current cart. It sends it's payload to the Chord OMS update order endpoint.

Parameters

Name

Type

options

ModifyCart

Returns

Promise<OrderBig>

A Promise that resolves when the cart object has been updated in Redux.

Defined in



modifyGiftCards

modifyGiftCards: (options: GiftCardsInput) => Promise<OrderBig>

Type declaration

▸ (options): Promise<OrderBig>

The modifyGiftCards function applies or removes gift cards from the current cart.

The giftCardsDetails object is returned in the lineItem object if the lineItem is a gift card. Additionally, newly redeemed gift cards are available in the user object for indicating to the user that they have received a gift.

The gift cards can be updated by including the gift card id along with any of the following params: recipientName, recipientEmail, giftMessage, purchaserName, sendEmailAt.The recipient email is a required field as that will be the account used to redeem the gift cards.



JS


Parameters

Name

Type

options

Returns

Promise<OrderBig>

A Promise that resolves when the cart object has been updated in Redux.

Defined in



modifyLineItem

modifyLineItem: (options: ModifyLineItem) => Promise<OrderBig>

Type declaration

▸ (options): Promise<OrderBig>

The modifyLineItem function updates a line item in the customer's cart. It calls Chord OMS's update order line item endpoint.

Parameters

Name

Type

options

Returns

Promise<OrderBig>

A promise that resolves when the cart has been updated in Redux.

Defined in



promoCode

promoCode: Object

Type declaration

Name

Type

isFetching

boolean

Inherited from

Omit.promoCode

Defined in



purchasePrepaidSubscription

purchasePrepaidSubscription: (input: PurchasePrepaidSubscription) => Promise<OrderBig>

Type declaration

▸ (input): Promise<OrderBig>

The purchasePrepaidSubscription function allows the customer to purchase a prepaid/gift subscription. The process is the caller provides a input of SKUs, quantities, installments, delivery frequency and shipping address and is returned an order that is outside of react-autonomy's state management ready to direct the customer straight to checkout. You should pass order.checkoutSessionId to your checkout provider to direct the customer to the next step.



This example is using Stripe for the checkout. It will allow the user to purchase a yearlog gift subscription for someone else.

JS


Parameters

Name

Type

input

Returns

Promise<OrderBig>

A promise containing a new order with just the subscription in it. You should pass it's checkoutSessionId to your checkout provider.

Defined in



redeemGiftCard

redeemGiftCard: (code: string, email: string) => Promise<GiftCardRedemption>

Type declaration

▸ (code, email): Promise<GiftCardRedemption>

The redeemGiftCard function redeems a gift card to the account matching the email provided during the initial purchase. It does not require the user to be logged in.



JS


Parameters

Name

Type

code

string

email

string

Returns

Promise<GiftCardRedemption>

Defined in



redeemPrepaidSubscription

redeemPrepaidSubscription: (payload: RedeemPrepaidSubscriptionInput) => Promise<GiftCardRedemption>

Type declaration

▸ (payload): Promise<GiftCardRedemption>

The redeemPrepaidSubscription function redeems a prepaid subscription to the account matching the email provided during the initial purchase. It does not require the user to be logged in.



JS


Parameters

Name

Type

payload

Returns

Promise<GiftCardRedemption>

Defined in



removeFromCart

removeFromCart: (options: RemoveFromCart) => Promise<OrderBig>

Type declaration

▸ (options): Promise<OrderBig>

The removeFromCart function removes a line item from the cart.

Parameters

Name

Type

options

Returns

Promise<OrderBig>

A Promise that resolves when the cart object has been updated in Redux.

Defined in



removePromoCode

removePromoCode: (options: RemovePromoCode) => Promise<OrderBig>

Type declaration

▸ (options): Promise<OrderBig>

The removePromoCode function removes an applied promo code from the cart.

Parameters

Name

Type

options

Returns

Promise<OrderBig>

A Promise that resolves when the cart object has been updated in Redux.

Defined in