skip to Main Content

I need a coupon code input on my cart page but it doesn’t seem to work in its plain form:

<input type="hidden" name="discount" value="{{ settings.modal_promo_code }}" >

I have it right before the submit button, inside the form.

Live coupons are not being applied to the order on the checkout page.

Is there anything else I need to do for it to work?

Edit: The form looks like this —

<form action="/cart" method="post" class="cart">
         <input type="hidden" name="discount" value="{{ settings.modal_promo_code }}" >

And it redirects to a URL like this:

https://store.com/4934605xxxx/checkouts/04d6478feeb9d3262fbea5571b682ebc?_ga=2.260083023.358228188.1608464294-110675315.1604953057

it seems there is a conflict that doesn’t let the discount apply to the URL or get removed by ?_ga=2.260083023.358228188.1608464294-110675315.1604953057 because when disabling the JS in the chrome setting and submitting the checkout again it works and the discount is getting applied.

any thoughts on this? how can I get this working like this:
https://store.com/4934605xxxx/checkouts/04d6478feeb9d3262fbea5571b682ebc?_ga=2.260083023.358228188.1608464294-110675315.1604953057&discount=TBSRWDVS

thank you

2

Answers


  1. As long as your cart isn’t utilizing AJAX to upgrade and divert this ought to work.

    The checkout page acknowledges a get contention of ?rebate= and including a field with a name="discount" will include that contention to the checkout.

    This works as it were in the event that you yield the standard shape specifically. (in the event that you overhaul the cart, the field rebate content will not be present and you wish to re-enter it again) If you must overhaul the shape you may get to keep the markdown code in a few ways, through overhauling the cart with ajax or putting away it as a cookie.

    So your code ought to be working, I twofold-checked it on my dev store and there are no issues, it applies a rebate to the checkout page since the get contention is present.

    PS: This does not include a rebate to the cart question, it is as it permitted for the checkout divert to incorporate a get contention, nothing else. So usually comparable to making an interface with

    Checkout

    Login or Signup to reply.
  2. A late response, but want to answer your questions and share a solution for this.

    First off no you cannot apply a discount code to cart the way you discribed, it is possible and doable but a bit more complicated than ading an input field to a form.

    There is no OOTB Shopify solution for this, but there is some undocumented API endpoints that can be used to create this feature.

    Check out Shopify Discounter Web Component, it supports:

    1. Discount codes
    2. Automatic discounts
    3. Gift cards
    4. Discount combinations
    5. Multi currencies
    6. Internalization
    7. Style customization using css variables
    8. Place it anywhere in your store

    Hope this helps.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search