use Carthook
Provides access to the cart object.
Anchor to PropsProps()
hook must be a descendent of a
component.
Anchor to Props-returnsReturns
CartWithActionsDocs
The cart's attributes.
A callback that updates the buyer identity in the cart. Expects the same input that you would provide to the Storefront API's
mutation.
A callback that updates the cart attributes. Expects the same attributes
input that you would provide to the Storefront API's mutation.
A callback that creates a cart. Expects the same input you would provide to the Storefront API's mutation.
The fragment used to query the cart object for all queries and mutations.
A callback that updates the cart's discount codes. Expects the same codes
input that you would provide to the Storefront API's mutation.
The cart lines.
A callback that adds lines to the cart. Expects the same lines
input that you would provide to the Storefront API's mutation. If a cart doesn't already exist, then it will create the cart for you.
A callback that removes lines from the cart. Expects the same lines
input that you would provide to the Storefront API's mutation. Only lines that are included in the
lines
parameter will be in the cart afterwards.
A callback that updates lines in the cart. Expects the same lines
input that you would provide to the Storefront API's mutation. If a line item is not included in the
lines
parameter, it will still exist in the cart and will not be changed.
A callback that updates the note in the cart. Expects the same note
input that you would provide to the Storefront API's mutation.
The status of the cart. This returns uninitialized
when the cart is not yet created, creating
when the cart is being created, fetching
when an existing cart is being fetched, updating
when the cart is updating, and idle
when the cart isn't being created or updated.
The cart's buyer identity.
A boolean indicating if the cart is ready to be interacted with.
The checkout URL for the cart, if the cart has been created in the Storefront API.
The cost for the cart, including the subtotal, total, taxes, and duties.
The discount codes applied to the cart.
If an error occurred on the previous cart action, then error
will exist and cart
will be put back into the last valid status it was in.
The cart's ID if it has been created through the Storefront API.
The cart's note.
The total number of items in the cart, across all lines. If there are no lines, then the value is 0.