Dedicated to the Hydrogen framework, headless commerce, and building custom storefronts using the Storefront API.
We are trying to display a form in the hero banner of our store. The purpose of the form is to apply a discount code to the cart at an earlier stage of the journey, rather than just in the cart. The store has been built using Hydrogen/Remix and GraphQL.
We are using the CartForm component. Is there a way of tapping in to the CartForm to return a success/error message should a code be added successfully or if a user inputs a string that is not a valid discount code and is not applied?
So far we have tried to store the current number of discount codes applied to the cart in a state variable and to then cross-reference this when the cart id becomes available and if the current number of codes has increased from the value taken from the previous state.
Has anyone done anything similar and if so could you share your approach on this please?