Short description of issue
cartCreate Mutation Ignoring Hidden Discount Input
Reproduction steps
input type=“hidden” name=“discount” value=“AXVNX”>
click “buy Now”
Additional info
I’m trying to implement a feature where a discount code is automatically applied when a customer clicks the “Buy It Now” button on the Product Detail Page.
My current approach: I added a hidden input field named discount inside the product form: ‘input type=“hidden” name=“discount” value=“AXVNX”>’
The issue: When clicking “Buy It Now”, the browser executes a cartCreate mutation to api/unstable/graphql.json. However, looking at the Network tab in DevTools, the discountCodes array in the payload remains empty: discountCodes: .
It seems the default Shopify scripts for the “Buy It Now” button (which usually triggers a dynamic checkout) do not pick up additional input fields from the form liquid to include them in the GraphQL mutation.
What I want to achieve: I need the discountCodes variable in the cartCreate mutation to be populated with my value (e.g., [“AXVNX”]) so the discount is applied immediately on the checkout page.
What type of topic is this
Troubleshooting

