Passing discount code from cart to checkout stopped working

Adrian20
Shopify Partner
41 0 2

For the past 5 years I've had code in the form section of the cart that passes a discount code to the checkout which then means that when the customer gets to the checkout it's already present and accepted.

Sometime yesterday this stopped working. There have been no changes to the cart code and I don't use any apps.

I spent a long time talking to Shopify Support yesterday the upshot of which was they said it wasn't their problem. I don't see how it can't be as something must have changed at the server end.


In the form section of the cart I have this line code where {{code_here}} would be a variable for the relevant discount code:

<input type="hidden" name="discount" value={{code_here}}>


If anyone has any ideas of how to get this working or know for a fact that Shopify have changed their end I would be grateful.

Of course if Shopify supported more than one Automatic Discount Code there would be no need for me to have this line of code and the rest of it that setups the correct normal discount code to use but that's another issue.

I'm not interested in using an app to do this. I do not use apps in my stores as I've had issues with data protection and apps just stopping working with no support so I do all my own development instead.

Reply 1 (1)
Adrian20
Shopify Partner
41 0 2

I've done a bit more digging around and it seems that there are different versions of checkout being presented by Shopify. Sometimes I get the "old" one which works correctly with my code and sometimes I get the "new" one that doesn't.

This is the code presented for the "new" one for the Discount Code input field:

<input id="TextField1" name="reductions" placeholder="Discount code" class="_1dc2V" type="text" aria-describedby="" aria-invalid="false" aria-labelledby="TextField1-label">


and this is the one for "old" version:

<input placeholder="Discount code" class="field__input" id="checkout_reduction_code" data-discount-field="true" autocomplete="off" aria-required="true" size="30" type="text" name="checkout[reduction_code]">


From what I can see the "new" version is going to break a lot of apps that have the same functionality as the code I use in my store.