# Rounding solution that can be used with new native currency converter tool

**URL:** <https://forum.wixstudio.com/t/rounding-solution-that-can-be-used-with-new-native-currency-converter-tool/9627>\
**Category:** Ask the community\
**Tags:** code, question\
**Created:** [September 10, 2021, 4:03pm UTC](https://forum.wixstudio.com/t/rounding-solution-that-can-be-used-with-new-native-currency-converter-tool/9627 "2021-09-10T16:03:32Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![info91340](https://avatars.discourse-cdn.com/v4/letter/i/ecd19e/32.png) [@info91340](https://forum.wixstudio.com/u/info91340)\
**Post date:** [September 10, 2021, 4:03pm UTC](https://forum.wixstudio.com/t/rounding-solution-that-can-be-used-with-new-native-currency-converter-tool/9627/1 "2021-09-10T16:03:32Z")

</div>

Hi,  
I’m delighted that Wix have launched the new currency converter tool but my client is looking for a specific rounded value to appear depending on client location. I can figure that bit out but haven’t had any luck finding a work around to get the €, $ £ etc. amounts to round up automatically i.e. £50.23 would appear as £50 and $100.78 would appear at $101.00 when converted from euro.

Has anyone found a way to do this or a third party fix?

---

<div class="post-metadata">

**Author:** ![giri-zano](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/giri-zano/32/80469_2.png) [@giri-zano](https://forum.wixstudio.com/u/giri-zano)\
**Post date:** [September 11, 2021, 12:22pm UTC](https://forum.wixstudio.com/t/rounding-solution-that-can-be-used-with-new-native-currency-converter-tool/9627/2 "2021-09-11T12:22:43Z")

</div>

Below my rounding function to do this. Call it, for instance, like

```javascript
let numRounded = fnRoundAmountMultiples(50.23, 1, "arith");
 

```

Expected result : 50

The function lets you choose a rounding method. Example:  
up: 50.23 rounded on 1 would be 51, 100.78 would be 101  
down: 50.23 rounded on 1 would be 50, 100.78 would be 100  
arith : 50.23 rounded on 1 would be 50, 100.78 would be 101

```javascript
function fnRoundAmountMultiples(numAmountIn, numRoundOn, strRoundType) {
    let numRoundedAmount = 0;
    let numDiv = numAmountIn / numRoundOn;
    let numMod = numAmountIn % numRoundOn; // calc modulo
    if (numMod === 0) return numAmountIn;
    let numModDivByUnit = numMod / numRoundOn; // devide mod by amount to round on
    let boolIsgeHalf = numModDivByUnit >= 0.5; // is it greater or equal than 0.5? Then Method is up for arithmetical
    let numBaseUp = Math.round(numDiv + 0.5);
    let numBaseDown = Math.round(numDiv - 0.5);
    let numRoundedUp = numBaseUp * numRoundOn;
    let numRoundedDown = numBaseDown * numRoundOn;
    switch (strRoundType) {
    case "up": // up
        return numRoundedUp;
    case "down": // down
        return numRoundedDown;
    case "arith": // arithmetical
        if (boolIsgeHalf) {
            return numRoundedUp;
        } else return numRoundedDown;
    }

}

```

---

<div class="post-metadata">

**Author:** ![info91340](https://avatars.discourse-cdn.com/v4/letter/i/ecd19e/32.png) [@info91340](https://forum.wixstudio.com/u/info91340)\
**Post date:** [September 11, 2021, 6:41pm UTC](https://forum.wixstudio.com/t/rounding-solution-that-can-be-used-with-new-native-currency-converter-tool/9627/3 "2021-09-11T18:41:08Z")

</div>

Thats great, I’ll try that, thank you so much.

---

<div class="post-metadata">

**Author:** ![gokdagerkan](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/gokdagerkan/32/4401_2.png) [@gokdagerkan](https://forum.wixstudio.com/u/gokdagerkan)\
**Post date:** [December 21, 2021, 11:36pm UTC](https://forum.wixstudio.com/t/rounding-solution-that-can-be-used-with-new-native-currency-converter-tool/9627/4 "2021-12-21T23:36:43Z")

</div>

Hello, I’m dealing with a similar issue. I want to synchronize the client’s browser language with the currency. However, the code I created did not meet what I wanted. The code you used might solve my problem in a different way. I would greatly appreciate it if you would be kind enough to share this code sample with me. Good work.

---

<div class="post-metadata">

**Author:** ![info91340](https://avatars.discourse-cdn.com/v4/letter/i/ecd19e/32.png) [@info91340](https://forum.wixstudio.com/u/info91340)\
**Post date:** [December 22, 2021, 10:42am UTC](https://forum.wixstudio.com/t/rounding-solution-that-can-be-used-with-new-native-currency-converter-tool/9627/5 "2021-12-22T10:42:21Z")

</div>

Hi, I couldn’t get it to work in the end I’m afraid

---

<div class="post-metadata">

**Author:** ![giri-zano](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/giri-zano/32/80469_2.png) [@giri-zano](https://forum.wixstudio.com/u/giri-zano)\
**Post date:** [December 23, 2021, 2:06pm UTC](https://forum.wixstudio.com/t/rounding-solution-that-can-be-used-with-new-native-currency-converter-tool/9627/6 "2021-12-23T14:06:52Z")

</div>

Guys, that code works, I use it myself. If it does not work for you, show us your code, only then can we help you.

---

<div class="post-metadata">

**Author:** ![Ilana\_Bar\_Rashi](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/ilana_bar_rashi/32/95361_2.png) [@Ilana\_Bar\_Rashi](https://forum.wixstudio.com/u/Ilana_Bar_Rashi)\
**Post date:** [August 9, 2024, 2:25pm UTC](https://forum.wixstudio.com/t/rounding-solution-that-can-be-used-with-new-native-currency-converter-tool/9627/7 "2024-08-09T14:25:35Z")

</div>

Hey, i tried pasting this in the masterpage.js and in the store pages, it wont work for me… but im new to this so maybe im missing something?
