Launch Afterpay Info Modal Anywhere
This page is a short guide on how to use JavaScript to enable any element to open the Afterpay information modal.
For the customer, it should be a single click operation; click on any element and the Afterpay information modal opens.
Instructions
Do the following:
-
Open your existing messaging script with an HTML editor.
-
Load
square-marketplace.js
script in the HTML, see the example below:
- Add
data-afterpay-modal
attribute to any element. When a customer clicks that element, it now opens the Afterpay information modal. Here’s an example code snippet that opens when a customer clicks the icon symbol:
Regional Modal Themes
For example:
<strong>[Afterpay Logo] <span data-afterpay-modal="en_NZ">ⓘ</span></strong>
Results in a modal suitable for New Zealand merchants.
<strong>[Afterpay Logo] <span data-afterpay-modal="en_AU">ⓘ</span></strong>
Results in a modal suitable for Australian merchants.
See similar examples in the Optional - Change Info Modal Theme section below.
Optional - Change Info Modal Theme
This is an option for merchants who want to use a non-default modal theme. Only assign a value to the data-afterpay-modal
attribute if you want to use a non-default modal theme.
Warning
If you try to assign an invalid value to the data-afterpay-modal
attribute, you will cause an error. For the standard Afterpay modal theme, leave the data-afterpay-modal
attribute without an assigned value.
Here is a code example of a default modal theme:
The code example above produces a standard Bondi Mint modal theme:
Here is a code example of a non-default modal theme:
The code example above has extra text in this line that defines the non-default theme:
<strong>[Afterpay Logo] <span data-afterpay-modal="en_AU-theme-white">ⓘ</span></strong>
Remember the default is Bondi Mint modal theme. The code example above produces a standard White modal theme that is not the default:
If you assign an incorrect value to the data-afterpay-modal=
part of the code, an error message appears: