Issues in getting 2 decimals to prices, eg €12,90

Rate this topic: Evaluations: 2, 3.50 on the average.Evaluations: 2, 3.50 on the average.Evaluations: 2, 3.50 on the average.Evaluations: 2, 3.50 on the average.Evaluations: 2, 3.50 on the average.Evaluations: 2, 3.50 on the average.3.50 out of 6 based on 2 vote(s)
GK User
Wed Sep 07, 2016 2:09 pm
Reply with quote
Report this post
Hi, on the category view prices are limited to 1 number after comma, I'd like to show 2 numbers (eg € 14,90 and not 14,9), so I went to /templates/gk_storebox/html/com_virtuemart/category/default.php
and tried to alter this code
Code: Select all
<span>
                           </ br><?php echo " ",'<span class="PricesalesPriceCat" style="color:white; font-size:12px;">'.$product->product_name.'</span>'; ?>
<!--                           </ br><?php echo " ",'<span class="PricesalesPriceCat" style="color:white; font-size:7px;">'.$product->product_s_desc.'</span>'; ?>-->
                           </ br><?php
                           if ($product->prices['salesPrice']>0)
                           echo " ",'<span class="PricesalesPriceCat" style="color:white; font-size:15px;">'."</ br>Prezzo: ".round($product->prices['salesPrice'],2)." &euro;".'</span>'; ?>
                     </span>

I tried altering the function round($product->prices['salesPrice'],2) to 3 or 4, but does not seem to be working.
I've also tried to remove it .$product->prices['salesPrice']. but the decimal number is always 1 (or 0).
Can anybody help me?
User avatar
Senior Boarder

GK User
Wed Sep 07, 2016 4:43 pm
Reply with quote
Report this post
Hi, Maybe this results. Virtuemart-Currencies-United States dollar for example
and put the field "Decimals" to 2
User avatar
Fresh Boarder

GK User
Wed Sep 07, 2016 5:10 pm
Reply with quote
Report this post
Sadly no, the settings you mentioned are already set to 2 decimals.
It's clearly controlled by the override in the html of the template, if I disable it, the decimals go back to 2, as in the rest of the pages...
User avatar
Senior Boarder

teitbite
Thu Sep 08, 2016 10:32 am
Reply with quote
Report this post
Hi

I think it has been cut before entering this partion of code. Try to force it to show 2 decimals with running it threw function: http://php.net/manual/en/function.number-format.php instead of round().
User avatar
Moderator

GK User
Thu Sep 08, 2016 11:13 am
Reply with quote
Report this post
Solved with your suggestion, teitbite, you're great as usual!
Code: Select all
.number_format($product->prices['salesPrice'],2,',','').
User avatar
Senior Boarder

teitbite
Mon Sep 12, 2016 1:31 pm
Reply with quote
Report this post
Hi
Glad I could help.
---
If You were satisfied with our support please let other users know on Twitter: http://twitter.com/gavickpro or Facebook: http://www.facebook.com/gavickpro
User avatar
Moderator


cron
Remember me
Register New Account
If you are old Gavick user, click HERE for steps to retrieve your account.