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.
Requirements
Anchor link to section titled "Requirements"- You've completed the quickstart guide.
- You've set up a cart handler.
Step 1: Read selected and available delivery groups
Anchor 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 form
Anchor link to section titled "Step 2: Create a select delivery option form"Use Remix's 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 action
and inputs
defined.
Step 3: Handle the selected delivery option form request
Anchor 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.