Update cart attributes
This guide shows you how to use the cart handler to update cart attributes.
Requirements
Anchor link to section titled "Requirements"- You've completed the quickstart guide.
- You've set up the cart handler.
Step 1: Create a form that will interact with a cart attribute
Anchor link to section titled "Step 1: Create a form that will interact with a cart attribute"Cart attributes are a list of key/value string pairs. The values can be anything you want to represent but they must be stored as strings. For example, you can add attributes that enable to add personalized messages to an order, such as requesting gift wrapping.
Use the CartForm
to create a cart attribute form. The component submits a form request to the /cart
route's action when a visitor submits an attribute key/value pair. You can use this component anywhere in the app.
Step 2: Handle the cart attribute form request
Anchor link to section titled "Step 2: Handle the cart attribute form request"Handle the cart attribute form request in an action
. Use the cart
that's created from createCartHandler
to handle cart mutation requests to the Storefront API.
- Learn how to apply discount codes.