Update selected delivery options
This guide shows you how to use a cart handler to update selected delivery options, such as standard or expedited delivery.
RequirementsAnchor link to section titled "Requirements"
Step 1: Read selected and available delivery groupsAnchor link to section titled "Step 1: Read selected and available delivery groups"
Carts return an empty array for available delivery groups by default. To get a list of delivery groups, the cart must be associated with a customer access token by updating the buyer identity when a customer is logged in.
Update the cart query fragment to return selected and available delivery options.
Step 2: Create a select delivery option formAnchor link to section titled "Step 2: Create a select delivery option form"
useFetcher hook to create a cart note form. The hook submits a form request to the
/cart route's action when users choose a delivery option. You can use this component anywhere in the app.
When you use
fetcher.submit, make sure there's a data key with the name
CartForm.INPUT_NAME. The key value must be a JSON stringified object with
Step 3: Handle the selected delivery option form requestAnchor link to section titled "Step 3: Handle the selected delivery option form request"
Handle the selected delivery option form request in an
action. Use the
cart, created from
createCartHandler, to handle cart mutation requests to the Storefront API.