932 B
932 B
The useCartLinesTotalQuantity
hook returns the total amount of items in the cart. It must be a descendent of a CartProvider
component.
Example code
import {CartToggle, useCartLinesTotalQuantity} from '@shopify/hydrogen';
export function CartButton() {
const quantity = useCartLinesTotalQuantity();
return <CartToggle>Cart {quantity}</CartToggle>;
}
Return value
The total amount of items in the cart.