Skip to main content

useCart

This hook is used to get the cart data.

propsTypeDescriptionExample
totalQuantityNumberTotal quantity of items in cart2
cartobjectCart object
lineItemsobjectArray of line items in cart
cartTotalPriceNumberTotal price of cart70
cartTotalPricelwithCurrencyStringTotal price of cart with currencyRs. 70
cartSubTotalAmountNumberSubtotal amount of cart30
cartTotalSavingsNumberTotal savings of cart40
cartTotalSavingsWithCurrencyStringTotal savings of cart with currencyRs. 40
cartTotalPayableStringTotal payable amount of cartRs. 30
cartTotalPayableWithCurrencyStringTotal payable amount of cart with currencyRs. 30
cartDiscountSavingsStringDiscount savings of cart30
cartDiscountSavingsWithCurrencyStringDiscount savings of cart with currencyRs. 30
cartTotalSavingWithoutDiscountNumberTotal saving without discount of cart10
cartTotalSavingWithoutDiscountWithCurrencyStringTotal saving without discount of cart with currencyRs. 10
shippingFeeNumberShipping fee of cart0
shippingFeeWithCurrencyStringShipping fee of cart with currencyRs. 0
isFreeShippingBooleanIs free shipping of carttrue
openCheckoutFunctionOpen checkout<button onClick={openCheckout}>Checkout</button>
canCheckoutBooleanCan checkouttrue
setCanCheckoutFunctionSet can checkout setCanCheckout(false);
checkoutLoadingBooleanCheckout loadingfalse

Usage:

import { useCart } from '@appmaker-xyz/shopify';
const { cart, setCanCheckout } = useCart(); // You can get the above props from this hook

image