How Do We Do ItĮxchangeRatesApi.io provides a REST API, offering the latest forex data for 168 currencies. Having access to exchange rate data via an API, we can implement this same functionality for our own online shops. ( Large preview)įinally, back on the product page, the price is displayed in euros: Product page in .uk, with price shown in euros. From among them, I’ve chosen the Euro: Dropdown with region settings. ( Large preview)Īfter clicking on “Change”, we are presented a select input, containing several pre-defined currencies. In the country/region settings, there is the option to change the currency: Dropdown with region settings. ( Large preview)īut we can also see the price in a different currency, if we wish to. When visiting a product page in .uk, we are presented the price in British pounds: Product page in .uk, with price shown in pounds. Simply said, we want to do what Amazon is doing: Give the option to the user in our online shop to display the prices in a currency of their own choosing. In this article, we will introduce ExchangeRatesApi.io, a popular API solution providing data for current and historical exchange rates for 168 currencies. ![]() ![]() Thanks to APIs providing currency exchange data, we can add a currency convertor to our online shops rather effortlessly. This means that we can’t have a pre-defined list of exchange rates stored in our application these must be gathered in real-time. To achieve that, we can convert the price of the item from a base currency (say, EUR) to the visitor’s currency (say, CNY) using the exchange rate between the two currencies at that specific time.Ĭurrency exchange rates change constantly, on an hourly basis (and even faster). If we want to provide a great user experience for them, to increase the chances of them buying our product, and coming back to the site, there is something very simple we can do: Display the price of the shopping items in their own currency. ![]() As we live in a global village, if we have an online shop, many of our visitors will quite likely be based on a different country than our own, and use a different currency than our own. Products and services are increasingly accessed and bought online. The default behavior is to return null for errors that occur during the request (connection timeout, DNS errors, client or server error status code, missing API success parameter, etc.).This article has been kindly supported by our dear friends at ExchangeRatesApi.io who provide developers with powerful data and conversion APIs for current and historical exchange rates. > source( 'ecb') // Switch data source between forex `default`, bank view or crypto currencies. > round( 2) // Round numbers to decimal places ![]() > amount( 5.66) // Specify the amount to be converted (default: 1) Enter the three-letter currency code of your preferred base currency. > base( 'GBP') // Changing base currency (default: EUR). > symbols() // An array of currency codes to limit output currencies > fluctuations( '', '') //`YYYY-MM-DD` Required dates range parameters Use AmrShawky\ LaravelCurrency\ Facade\ Currency
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |