useCart
This hook is used to get the cart data.
props | Type | Description | Example |
---|---|---|---|
totalQuantity | Number | Total quantity of items in cart | 2 |
cart | object | Cart object | |
lineItems | object | Array of line items in cart | |
cartTotalPrice | Number | Total price of cart | 70 |
cartTotalPricelwithCurrency | String | Total price of cart with currency | Rs. 70 |
cartSubTotalAmount | Number | Subtotal amount of cart | 30 |
cartTotalSavings | Number | Total savings of cart | 40 |
cartTotalSavingsWithCurrency | String | Total savings of cart with currency | Rs. 40 |
cartTotalPayable | String | Total payable amount of cart | Rs. 30 |
cartTotalPayableWithCurrency | String | Total payable amount of cart with currency | Rs. 30 |
cartDiscountSavings | String | Discount savings of cart | 30 |
cartDiscountSavingsWithCurrency | String | Discount savings of cart with currency | Rs. 30 |
cartTotalSavingWithoutDiscount | Number | Total saving without discount of cart | 10 |
cartTotalSavingWithoutDiscountWithCurrency | String | Total saving without discount of cart with currency | Rs. 10 |
shippingFee | Number | Shipping fee of cart | 0 |
shippingFeeWithCurrency | String | Shipping fee of cart with currency | Rs. 0 |
isFreeShipping | Boolean | Is free shipping of cart | true |
openCheckout | Function | Open checkout | <button onClick={openCheckout}>Checkout</button> |
canCheckout | Boolean | Can checkout | true |
setCanCheckout | Function | Set can checkout | setCanCheckout(false); |
checkoutLoading | Boolean | Checkout loading | false |
Usage:
import { useCart } from '@appmaker-xyz/shopify';
const { cart, setCanCheckout } = useCart(); // You can get the above props from this hook