Example Description
In this example, site visitors select source and target currencies and specify an amount for conversion. After running the conversion, the target amount and timestamp of the conversion are displayed.
How We Built It
Page Elements
In our site we added the following elements:
2 text inputs: for entering the amount to convert from, and for displaying the converted amount in the target currency
2 dropdowns: for selecting the source and target currencies
Button: for triggering the conversion
Text element: for displaying the timestamp of the conversion rate
Page Code
Our code does the following:
Import the currencies API from the wix-pay module.
When the page loads, get all the currencies that Wix supports for currency conversion.
Sort the currencies alphabetically.
Set the currencies as the dropdown options.
When a site visitor clicks the Convert button, do the following:
Get the amount to convert from the input and change it from a string to a number.
Get the source and target currencies from the dropdowns.
Convert the amount and get the result.
Display the result.
Display the exchange rate timestamp in the text element.
Related Examples
Did this help?
|
Thanks for your feedback!
Customized Form
Customize a form with conditional logic
Intermediate
Collect Payments for a Single Product
Collect quick and secure payments from your site visitors.
Intermediate