We’ve migrated our documentation to a new site, which means some URLs have changed.
Subscriptions

How to pre-fill the Promo Code Input Field in the Checkout

If you want to unburden users from manually entering the promo code that they've received, you can utilize one of the 2 below options to have the promo code automatically pre-filled in checkout.

1. Include the promo code as an URL parameter. For example, when a user clicks on an email link with an offer, they will be redirected to a page with the promo code parameter already filled in. Please note, that on this page, the offer will need to be presented.

For example https://website.com?promo_code=PROMO123

2. Show an offer programmatically using JavaScript and include the promoCode parameter, like this:

  tp.offer.show({
        offerId: "<offer_ID>",
        templateId: "<template_ID>",
        displayMode: "modal",
        promoCode: "<promo_code>"
    });

For example, below is a code snippet with real values. You would just replace the values with the ones from your Piano dashboard.

  tp.offer.show({
        offerId: "OFPRLHTJMQPB",
        templateId: "OTDKTCUTXMPL",
        displayMode: "modal",
        promoCode: "PROMO123"
    });

More information on manually triggering offers with JavaScript can be found here.

Last updated: