DynamicPricing.js reference
Reference documentation for the DynamicPricing.js library
Last updated
Reference documentation for the DynamicPricing.js library
Last updated
This page documents the scripts, element attributes, and functions in Digital River's browser-side DynamicPricing.js library.
On each html
page that contains , you must have a script
with an id
of DR-Dynamic-Pricing
.
Except for the , the following code must remain unaltered:
data-dr-apiKey
data-dr-currency-selector
You can optionally set data-dr-currency-selector
. If you do, a DOM element whose id
is the same value as data-dr-currency-selector
needs to be on the page.
The default value is DR-currencySelector
.
data-dr-default-country
You can use the optional data-dr-default-country
attribute to help determine which country is selected by default when a page loads. By extension, this also determines the selected currency.
Alternatively, you can override this stylesheet with your own.
Each DOM element on your site that displays pricing information must have a data-dr-original-price
attribute. These represent your base prices. Ensure the values you pass don't contain a currency symbol or whitespace.
digitalRiverPricing.getCountry()
digitalRiverPricing.getCurrency()
In the , the following attributes are configurable:
You must set data-dr-apiKey
and the value you pass must be your .
For more details, refer to .
The value you pass must be a two-letter as described in the international standard.
When the page loads and the executes, it first looks for the user's country in cookies, next in data-dr-default-country
, and then in the browser's default language settings. If those searches aren't successful, your account's is used.
Once a value is located, DynamicPricing.js calls to determine that country's default currency. The drop-down menus display these country and currency values. Additionally, your are denoted in this currency.
The allows customers to select a country-currency combination while shopping on your site.
To configure it, you must (1) and (2) .
You need to include a DOM element that renders the . The element can be added to the header, footer, body, and HTML tags.
The element's id
must be (1) DR-currencySelector
or (2) the value you assign .
If you don't set , then id
of the selector element must be DR-currencySelector
If you set , then id
of the selector element must have the same value.
To style the , add the following link
.
When populating your data-dr-original-price
attributes, retrieve data from a price list associated with your account's .
To retrieve your base country and currency, pass your in the header of a GET /dynamic-pricing/country-currency
request.
Also, depending on , make sure that your data-dr-original-price
values are either tax-inclusive or tax-exclusive. For details, contact your Digital River representative.
When the executes or customers modify currency and/or country in the , DynamicPricing.js makes a call to get country-currency specific data, and then checks whether the country is both supported by Digital River and set up to allow . If these conditions are met, DynamicPricing.js applies a conversion factor and a to each data-dr-original-price
on the page, implements , and then displays the converted, formatted value in the DOM element's innerHTML
and adds data-dr-converted-price
and data-dr-formatted-price
to the element's attributes.
The creates the digitalRiverPricing
object which exposes )
and .
Call digitalRiverPricing.getCountry(
) to get the country that is selected in the.
The returned value is formatted as an .
Call digitalRiverPricing.getCurrency()
to get the currency that is selected in the .
The returned value is formatted as a three-letter alphabetic code that conforms to the standard.