Jump to content
Poppy381

Tips to round prices with NO decimals displayed with Prestashop 1.7.

Recommended Posts

Ok the problem is that the Prestashop team change a lot of things with currencies to use cldr.

The decimals feature does not work anymore even if the feature is on the BO.

Well after several hours of research I've find that :

 

 

If you want to know the conversion_rate, it's not visible on smarty debug windows but here :

 

$conversion_rate = $this->context->currency->conversion_rate;
$this->context->smarty->assign('conversion_rate',$conversion_rate);

Now, for the ROUND price. First configure Prestashop to really round your prices. Even if you round theme and select 0 decimals, 2 decimals will always been displayed. That's because prestashop 1.7 does not refer to your settings (thank you guys...) but to cldr.

 

If you want to know the format of your currency try this :

$currency_format = $this->context->currency->format;
echo $currency_format,
break;

The format is store in a local file in >Translations>cldr>main-en-US-numbers or main-fr-FR-numbers etc.

 

Open the file and find "currencyFormats-numberSystem-latn"

"currencyFormats-numberSystem-latn":{"currencySpacing":{"beforeCurrency":{"currencyMatch":"[:^S:]","surroundingMatch":"[:digit:]","insertBetween":"\u00a0"},"afterCurrency":{"currencyMatch":"[:^S:]","surroundingMatch":"[:digit:]","insertBetween":"\u00a0"[spam-filter],"accounting":"#,##0.00\u00a0\u00a4;(#,##0.00\u00a0\u00a4)","standard":"#,##0.00\u00a0\u00a4","unitPattern-count-one":"{0} {1}","unitPattern-count-other":"{0} {1}"}

you will find the currency format.

 

$ format :

standard:\u00a4#,##0.00

€ format :

standard: #,##0.00\u00a0\u00a4

\u00a4 is the currency sign

 

\u00a0 is a space

 

The coma is the thousand(group) separator and The point is the decimal separator.

They are defined at the beginning of the file :

"symbols-numberSystem-latn":{"decimal":".","group":",";

If you don't want to see decimals on your shop, just delete ".00" and save the file, and that's all :).

 

 

I suggest to Prestashop team to allow us to have a variable to display or not decimals instead of doing that :)

 

All the best

Franck

Edited by Poppy381
  • Like 8
  • Thanks 2

Share this post


Link to post
Share on other sites

Well the first thing to do is to create your own thread on this forum and don't ask a question about something different in a thread...Please delete your message, you will have more answer in your own thread with a good title.

 

Thank you.

Share this post


Link to post
Share on other sites

Thanks for share!

 

But it's works? how do it, you can help i fix prestashop v1.7.2.1

 

Thanks!

 

hi Truong

as I suggested you, this topic is the original post which gives the solution

Edited by ets-soft

Share this post


Link to post
Share on other sites

Original post ? This topic answers to this problem on 29th November 2016 by myself, your topic on 29 June 2017 ?

I don't understand why you post another link to another forum as the answer is still here in the first post, with all explanations. Right ?

Share this post


Link to post
Share on other sites

Original post ? This topic answers to this problem on 29th November 2016 by myself, your topic on 29 June 2017 ?

I don't understand why you post another link to another forum as the answer is still here in the first post, with all explanations. Right ?

 

hi Poppy381

sorry for the mistake, I didn't know your post is original. @Trung Huynh asked us for help on another forum, I was looking for a solution on Google and saw it on stackoverflow and gave him that solution. I have edited the previous post

Share this post


Link to post
Share on other sites

Hi, I have tree currencies in my store, but I don't know how to configurate the correct currency format for every one.

 

EUR is X,XXX.XX €

USD is $X,XXX.XX

COP is $ X.XXX

 

I will waiting for a response (Sorry for my english)

Share this post


Link to post
Share on other sites

Hi,

Thanks, this worked well :)

Can i edit this file in order to make the prices end with a "9", for example 109?

Share this post


Link to post
Share on other sites

Sadly it doesn't work for me. I've edited the numbers.json according to your information in translations/cldr/datas/main/ko-KR. I don't use a CDN, caching is diabled and theme compiling is forced. None of the changes take effect. Even if I delete the content of the whole file.

Share this post


Link to post
Share on other sites
11 minutes ago, Vailry said:

Sadly it doesn't work for me. I've edited the numbers.json according to your information in translations/cldr/datas/main/ko-KR. I don't use a CDN, caching is diabled and theme compiling is forced. None of the changes take effect. Even if I delete the content of the whole file.

 

Clear cache and try again. If you delete the file and nothing change, it should help you to understand...Maybe something change on last version...

 

Share this post


Link to post
Share on other sites

Hello,
can you also advise me how to delete the decimal places in discount flags the list of products? E.g. 17.35% discount does not look nice. I would only show 17% (from 17.5% to 18%), etc.
"percentFormats-numberSystem-latn": {"standard": "#, ## 0 \ u00a0%"}, = 0 decimal places, but show all
Thank you in advance for your advice.

Share this post


Link to post
Share on other sites

Hello, I have the same issue, need to display Russian Ruble with no decimals, and Euro with 2 decimals.  

Is there a possible solution for multiple currencies?

Share this post


Link to post
Share on other sites

This solution is half working actually. If you remove .00 but your items has prices with decimals then final price will be incorrectly calculated in the basket.

As for an examle: you have product#1 with price "10.55", if you remove .00 at standard section of the file then its price will be shown at frontend as "10" but if you add 2 pcs of product#1 to the basket final price will be "21" but not "20". Additional removal of .00 at accounting section of the file does nothing.

Any ideas?

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×

Important Information

Cookies ensure the smooth running of our services. Using these, you accept the use of cookies. Learn More