[SOLVED ]Automatically apply coupon


I would love to know if there is a trick / way to automatically apply a coupon code at the payment step?

Basically, I will set up one coupon, and instead of letting users fill the code section, It’ll be automatically be applied.

Thanks a lot for your help.


Hi Olivier,

We don’t have a built in way to do that yet. That said, we do have a feature idea that would make this possible.

For now, you would need to use a bit of JS to automatically click on the coupon button, and add the coupon. Definitely easier said than done, but possible :slightly_smiling_face:

Do you know JS? If not, we can help connecting you with a dev.

1 Like

Thanks for the answer!

Alright, I’ll probably implement that in the future!

Thanks again!

1 Like

Here is the code needed, just in case someone needs it:


$(window).on('load', function(){
        var event = new Event("input", {
          bubbles: true,
          cancelable: true,
      $('#msCouponId')[0].value = "COUPONCODE";
    }, 500);


Hi Olivier!

Good stuff! Thanks for posting this :grinning:

This sound cool! Could you tell me where would I need to add this code? Also, how does the code know wich coupon code to chose? Thank you for your help!

Hey Bentot :wave:

I’ll let Olivier correct me if I’m wrong, but I believe you need to add the script to the footer of your site, and replace: COUPONCODE with the name of your coupon.

Hey Kamel,

I’ve a subscription page, where users can select the offer they want to subscribe for.
It’s on this page I added the code, Before tag.
(It’s the page before the stripe form).

Quick note, I updated the code since then, not sûre if It’s still working.
Will advice you to check with a developper to make it works as you would like.

1 Like

Hey just bumping this because it’s a pretty critical function for me.

Is it possible to have this code appear on a single page only? I am working in Squarespace and there is an option to inject code on a single page but the code inject automatically goes to the header section. Is that why its maybe not activating vs injecting it in footer?

My goal is to offer affiliates the ability to route people to their unique page, on which their specific coupon is already applied, so their fans can check out with the coupon code auto applied as they land on that page only.

Does that make sense? Should I inject this script into the single page? I can’t manage to get it to apply. I am using the #/ms/signup/5e82c5f260d85c0017740f55 (my memID) ending on a button that activates the pop up modal.

Any idea how to get this set up on individual pages? Or why my modal is not reading it? Any insight would be incredible this could be a game changer for me and hopefully others.

Seems I’ve got it working but users still have to press ‘Got Coupon Code’ is there a way for this to auto be applied?

Here’s the updated code for getting this to work.

MemberStack.onReady.then(function() {
  setTimeout(function() {
        const box = document.querySelector("[ms-lang='pay_coupon']")
        box.value = "100off"
        box.dispatchEvent(new Event('input', { 'bubbles': true }))