Hide the option to add a discount at checkout
Use a parameter or HTML data attribute when working with Paddle.js to hide the option to add a discount at checkout.
What's new?
We added a new parameter to the Paddle.Checkout.open()
method and Paddle.Initialize()
methods that you can use to hide the option to add a discount at checkout when working with Paddle.js:
Set general checkout settings.
Whether the option to add a discount is displayed at checkout. Requires the "display discount field on the checkout" option enabled in Paddle > Checkout > Checkout settings. Defaults to true
.
We also added a corresponding HTML data attribute:
Whether the option to add a discount is displayed at checkout. Defaults to true
.
How it works
Paddle Checkout includes an "Add Discount" option to let customers enter a discount code. Seeing the option to add a discount might make some customers reluctant to purchase if they don't have a code. You might also want to hide it if you don't generally offer discounts.
The new showAddDiscounts
settings parameter and data-show-add-discounts
HTML data attribute lets you hide the option to add a discount at checkout when working with Paddle.js.
You can pass settings for opened checkouts using either Paddle.Checkout.open()
or Paddle.Initialize()
. Settings passed to Paddle.Initialize()
are default settings, applied to all checkouts opened on a page.
This change removes the option for customers to apply a discount themselves, but you can still prefill discounts when opening a checkout using
discountCode
anddiscountId
parameters, ordata-discount-code
anddata-discount-id
HTML data attributes.
Examples
This example includes the settings
object as part of the checkout open method. showAddDiscounts
set to false
, meaning the option to "Add discount" is hidden for the opened checkout.
The settings passed here only apply to the opened checkout.
12345678910111213141516171819201var itemsList = [
2 {
3 priceId: 'pri_01gm81eqze2vmmvhpjg13bfeqg',
4 quantity: 1
5 },
6 {
7 priceId: 'pri_01gm82kny0ad1tk358gxmsq87m',
8 quantity: 1
9 }
10];
11
12Paddle.Checkout.open({
13 settings: {
14 displayMode: "overlay",
15 theme: "light",
16 locale: "en",
17 showAddDiscounts: "false"
18 },
19 items: itemsList,
20});
This example sets default checkout settings for all checkouts opened on a page. showAddDiscounts
set to false
, meaning the option to "Add discount" is hidden for all opened checkouts on the page.
12345678910111Paddle.Initialize({
2 token: 'live_7d279f61a3499fed520f7cd8c08',
3 checkout: {
4 settings: {
5 displayMode: "overlay",
6 theme: "light",
7 locale: "en",
8 showAddDiscounts: "false"
9 }
10 }
11});
This example shows hiding the option to add a discount passed as an HTML data attribute against a Paddle Checkout element.
It includes checkout settings and items.
12345678910111213141516171819201<a href='#'
2 class='paddle_button'
3 data-display-mode='overlay'
4 data-theme='light'
5 data-locale='en'
6 data-allow-logout='false'
7 data-items='[
8 {
9 "priceId": "pri_01gm81eqze2vmmvhpjg13bfeqg",
10 "quantity": 1
11 },
12 {
13 "priceId": "pri_01gm82kny0ad1tk358gxmsq87m",
14 "quantity": 1
15 }
16 ]'
17 data-show-add-discounts='false'
18>
19 Buy now
20</a>
Next steps
This change is live in Paddle.js now, so you can start using showAddDiscounts
or data-show-add-discounts
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.