The optional priceElement represents an array of CSS selector strings that DigitalRiverCheckout.js uses to target each element on your page that displays pricing information.
For example, span.price in the following priceElement targets all <span> elements that have a class attribute of "price".
When users modify currency or country in the selector, we make a call to determine whether Digital River supports that country, and it's set up for variable pricing. If this is the case, for each priceElement, we apply a conversion factor and a rounding function, implement currency formatting rules, and display a converted, formatted value in its innerHTML and add selected currency, selected country, converted price, formatted price, and original price attributes.
The optional onOpen property can be assigned a callback method that executes when the user clicks on the country-currency icon and the local pricing selector opens.
onSelect
The optional onSelect property can be assigned a callback method, which accepts data, that executes when the user makes a selection in the local pricing selector. In data, the method returns either country or currency, depending on which the user selected.
onSave
The optional onSave property can be assigned a callback method, which accepts data, that executes when the user clicks the local pricing selector's save button. In data, the method returns the country and currency that the user saved.
onCancel
The optional onCancel property can be assigned a callback method that executes when the user clicks the local pricing selector's cancel button.
const config = {
countrySelector: {
...
onOpen: () => {
console.log('The user opened the country-currency selector');
},
...
}
};
const config = {
countrySelector: {
...
onSelect: (data) => {
if (data.hasOwnProperty('country')) {
console.log('The user selected the country of ' + data.country)
} else {
console.log('The user selected a currency of ' + data.currency);
}
},
...
}
};
const config = {
countrySelector: {
...
onSave: (data) => {
console.log('The user clicked the save button. The saved country and currency is ' + data.country + ' and ' + data.currency + ", respectively");
},
...
}
};
const config = {
countrySelector: {
...
onCancel: () => {
console.log('The user clicked the cancel button');
}
}
};