Paddle Billing
Search

Pass a discount code to Paddle.js

We added a new parameter and HTML data attribute to Paddle.js to let you pass a discount code when opening a checkout.

What's new?

We added a new parameter to the Paddle.Checkout.open() method that you can use to pass a discount code to Paddle.js when opening a checkout:

discountCodestring or null

Discount code to apply to this checkout. Use to pre-populate a discount. Pass either discountCode or discountId.

We also added a corresponding HTML data attribute:

data-discount-codestring

Discount code to apply to this checkout. Use to pre-populate a discount. Pass either data-discount-code or data-discount-id.

This complements the existing discountId parameter and data-discount-id HTML data attribute, which let you pass the Paddle ID of a discount when opening a checkout.

How it works

Previously, you could pass discountId or use the data-discount-id HTML data attribute to pre-populate a discount when opening a checkout. These fields accept the Paddle ID of a discount entity.

The new discountCode parameter and data-discount-code HTML data attribute let you pass a discount code instead. This means that if you know the discount code for a discount, you don't need to make an additional call to the API or use the Paddle dashboard to get its ID.

Discount codes are set against discount entities in Paddle. They're optional, letting you create a customer-facing code that customers can enter at Checkout, sometimes called "coupons."

Examples

Next steps

This change is live in Paddle.js now, so you can start using discountCode or data-discount-code when you're ready.

You don't need to do anything to get the latest version of Paddle.js — we serve the latest version automatically.

Learn more