how to get the current currency from the currency converter

I can’t find a property on the currency converter that represents the selected currency on the currency converter. Is there a way to retrieve it?

Hi Hashim :raised_hand_with_fingers_splayed:

At the moment, it’s not possible to get the current currency from the currency converter.

Thanks for your answer Ahmad; do you know if it will be available anytime soon?

I’ve submitted a feature request to the Wishlist , keep an eye of this list for a few days and vote for the feature when it’s published there.

Hello, I’ve been following that request for a while; I see that the title is changed and set as “released” but I still cannot find the ability to get the current currency.

Bump

Hey @dashinghbk66 , I’ve revised the documentations and couldn’t find the currency converter element’s APIs, perhaps they’re still adding its documentation to the API reference, give them a few more days, or create a custom one as I did.

@ahmadnasriya Hey Ahmad! Do you have the code for that custom currency converter? My store isn’t designed with the default wix stores pages, but with dynamic ones. I need it to be in the header and give the option of converting prices to another currency in the all products page, the product page and the cart. The currency converter app does not work here (only in the cart). Maybe there is a way to use the currency converter, get the current currency and apply it to my text items that are connected to the product price field. I checked all the api there is but I don’t how to code it. Any help would be really appreciated!

@eugeniagarat https://www.wix.com/velo/example/currency-converter

@certified-code hey! thank you for your response! I actually achieved some code working thanks to that example with a little twist, and it works perfectly in my product page. The thing is, I need it to work the same as the currency converter app, meaning for it to work as well in the cart and in the all products page. My all products dynamic page is designed with a wix pro gallery (I´ld have loved to use a repeater but sadly they don’t adapt to the screen width, which is a no go for me), and I can’t find a clear way to access to it with code in order to make the same conversion I did in the product page, in this case I would need to connect the conversion result to the description element in the gallery. Also, I need it to work in the cart for it to convert the products prices and the shipping price. This I could do if I somehow change the hole site currency (I have currencies instaled just not using the app dropdown) as that works perfectly in the cart. But I also can’t find a way to access the current site currency and set another one on dropdown change.
Also the dropdown is in the header so I would use the storage api to store it’s state so that it automatially converts prices on ready acording to what the client selected on the previous page.
Do you think I could achieve all this? Please consider I’m new at code, I’m just learning as I go to design my page, so I can make little tweaks but I don’t fully understand APIs neither I’m able to write codes from cero.

This is my product page currency converter code:


  $w('#price').text = $w('#dynamicDataset').getCurrentItem().formattedPrice;

  initDropdowns();
    $w('#currency').onClick(() => conversionHandler());


async function initDropdowns() {
    const listOfAllCurrencies = await currencies.siteSettings.getCurrencies();
    const optionsArray = formAsDropdownOptions(listOfAllCurrencies);
    optionsArray.sort((option1, option2) => compareOptionsAlphabetically(option1.label, option2.label));
    $w('#currency').options = optionsArray;

}

function formAsDropdownOptions(listOfAllCurrencies) {
    const optionsArray = listOfAllCurrencies.map((currencyItem) => {
        return {
            'value': currencyItem.code,
            'label': currencyItem.code,
            "symbol": currencyItem.code,
        }
    });
    return optionsArray;
}

function compareOptionsAlphabetically(label1, label2) {
    if (label1 > label2) {
        return 1;
    }
    return -1;  
}


async function conversionHandler() {
let item = $w("#dynamicDataset").getCurrentItem();
 //gets price of current product
let amount = item.price;
 console.log (amount)

    const toCurrency = $w('#currency').value;
    const convertionResult = await currencies.currencyConverter.convertAmounts({
        'amounts': [amount],
        "from": "ARS",
        'to': toCurrency
    });
    const result = String((convertionResult.amounts[0]));
    $w('#price').text = parseFloat(result).toFixed(2) + "$"
  
}


I changed it so that I only use one dropdown that shows the currencies I instaled, and it takes the formatted price of the current product as the value to convert, converts it according to the dropdown selection and displays it in the “price” text object. It works perfectly, it just doesn’t show as an option ARS which is Argentinian peso currency, my site currency. So if I wan’t to change it back to ars, I can’t.

Thanks!
Euge