Interface: UseCart
react-autonomy.UseCart
UseCart contains the data and methods returned by the useCart hook.
- Omit<RootInitialState["cart"], "data">↳
▸ (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.
Name | Type |
---|---|
options | CrossSell |
Promise<OrderBig>
• addPromoCode: (options: AddPromoCode) => Promise<OrderBig>
▸ (options): Promise<OrderBig>
The addPromoCode function applies a promo code to the current shopping cart.
Name | Type |
---|---|
options | AddPromoCode |
Promise<OrderBig>
• addSubscription: (subscription: AddSubscriptionItem) => Promise<OrderBig>
▸ (subscription): Promise<OrderBig>
The addSubscription function adds a subscription item to the customer's cart.
Name | Type |
---|---|
subscription |
Promise<OrderBig>
• addToCart: (items: AddToCartItem | AddToCartItem[]) => Promise<OrderBig>
▸ (items): Promise<OrderBig>
The addToCart function adds a product variant to the current shopping cart (creating a line item).
Name | Type | Description |
---|---|---|
items | AddToCartItem | AddToCartItem[] | The items to add to the cart. |
Promise<OrderBig>
A Promise that resolves once the items are added to the cart.
• cart: Partial<OrderBig>
An object representing the current shopping cart.
• checkRedemptionCodeValidity: (code: string, email: string) => Promise<OrderBig>
▸ (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.
Name | Type |
---|---|
code | string |
string |
Promise<OrderBig>
A Promise that resolves with the order the redemption code is valid for.
• emptyCart: () => Promise<OrderBig>
▸ (): Promise<OrderBig>
The emptyCart function clears the customer's cart contents (line items, promo codes, metadata) while keeping the same order number.
Promise<OrderBig>
• error: Error
Omit.error
• forgetCart: () => { type: string = FORGET_CART }
▸ (): Object
The forgetCart function clears the customer's cart.
Object
Name | Type |
---|---|
type | string |
• isFetching: boolean
Omit.isFetching
• isLoaded: boolean
Omit.isLoaded
• loadCart: () => Promise<OrderBig>
▸ (): 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.
Promise<OrderBig>
A Promise that resolves when the cart object has been added to Redux.
• modifyCart: (options: ModifyCart) => Promise<OrderBig>
▸ (options): Promise<OrderBig>
The modifyCart function modifies the current cart. It sends it's payload to the Chord OMS update order endpoint.
Name | Type |
---|---|
options | ModifyCart |
Promise<OrderBig>
A Promise that resolves when the cart object has been updated in Redux.
• modifyGiftCards: (options: GiftCardsInput) => Promise<OrderBig>
▸ (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.
Name | Type |
---|---|
options |
Promise<OrderBig>
A Promise that resolves when the cart object has been updated in Redux.
• modifyLineItem: (options: ModifyLineItem) => Promise<OrderBig>
▸ (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.
Name | Type |
---|---|
options |
Promise<OrderBig>
A promise that resolves when the cart has been updated in Redux.
• promoCode: Object
Name | Type |
---|---|
isFetching | boolean |
Omit.promoCode
• purchasePrepaidSubscription: (input: PurchasePrepaidSubscription) => Promise<OrderBig>
▸ (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.
Name | Type |
---|---|
input |
Promise<OrderBig>
A promise containing a new order with just the subscription in it. You should pass it's checkoutSessionId to your checkout provider.
• redeemGiftCard: (code: string, email: string) => Promise<GiftCardRedemption>
▸ (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.
Name | Type |
---|---|
code | string |
string |
Promise<GiftCardRedemption>
• redeemPrepaidSubscription: (payload: RedeemPrepaidSubscriptionInput) => Promise<GiftCardRedemption>
▸ (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.
Name | Type |
---|---|
payload |
Promise<GiftCardRedemption>
• removeFromCart: (options: RemoveFromCart) => Promise<OrderBig>
▸ (options): Promise<OrderBig>
The removeFromCart function removes a line item from the cart.
Name | Type |
---|---|
options |
Promise<OrderBig>
A Promise that resolves when the cart object has been updated in Redux.
• removePromoCode: (options: RemovePromoCode) => Promise<OrderBig>
▸ (options): Promise<OrderBig>
The removePromoCode function removes an applied promo code from the cart.
Name | Type |
---|---|
options |
Promise<OrderBig>
A Promise that resolves when the cart object has been updated in Redux.