Cart hooks

This guide provides a list of the cart hooks offered in Hydrogen.

Cart

A cart contains the merchandise that a customer intends to purchase and the estimated cost associated with the cart. When a customer is ready to purchase their items, they can proceed to checkout.

Reference

Hydrogen includes the following cart hooks:

Hook name Description
useCart Provides access to the Storefront API's Cart object.
useCartAttributesUpdateCallback Returns a callback that can be used to update the cart's attributes.
useCartBuyerIdentityUpdateCallback Returns a callback that can be used to update the cart's buyer identity.
useCartCheckoutUrl Returns a string of the checkout URL for the cart.
useCartCreateCallback Returns a callback that can be used to create a cart.
useCartDiscountCodesUpdateCallback Returns a callback that can be used to update the cart's discount codes.
useCartLine Provides access to the Storefront API's CartLine object.
useCartLinesAddCallback Returns a callback that can be used to add lines to a cart. If a cart doesn't already exist, then it will create the cart for you.
useCartLinesRemoveCallback Returns a callback that can be used to remove lines from a cart.
useCartLinesTotalQuantity Returns the total amount of items in the cart.
useCartLinesUpdateCallback Returns a callback that can be used to update lines in a cart.
useCartNoteUpdateCallback Returns a callback that can be used to update the cart's note.

On this page