Update discount codes
This guide shows you how to use a cart handler to apply discount codes to a cart.
Requirements
Anchor link to section titled "Requirements"- You've completed the quickstart guide.
- You've set up a cart handler.
Step 1: Create a discount code form
Anchor link to section titled "Step 1: Create a discount code form"Use the CartForm
to create a discount code form. You can use this component anywhere in the app. It will submit a form request to the /cart
route's action when a visitor submits a discount code.
Step 2: Handle the discount code form request
Anchor link to section titled "Step 2: Handle the discount code form request"Handle the discount code form request in an action
. Use the cart
, created from createCartHandler
, to handle cart mutation requests to the Storefront API.
- Learn how to apply selected delivery options.