Post by pla1829 » Thu Dec 29, 2016 12:48 am

I saw a post here: viewtopic.php?f=20&t=42133

It recommends to hide the .00 when it is .00 and only show decimals when they are needed (ie: .68) to change the following code in system/library/currency.php:

Code: Select all

return $string;
Into:

Code: Select all

return str_replace('.00','',$string);

I did a quick search in OpenCart 2.3.0.2 and noticed it does not have a system/library/currency.php

How does one go about making such a modification in OpenCart 2?

New member

Posts

Joined
Sat Nov 22, 2014 12:16 pm

Post by opencartmart » Thu Dec 29, 2016 1:22 am

In OC 2.3.0.2, currency.php is located at system/library/cart/currency.php

XForm - Opencart Form Builder

Xshippingpro - An advanced Shipping Module


Active Member

Posts

Joined
Wed Oct 02, 2013 3:59 am

Post by pla1829 » Thu Dec 29, 2016 1:29 am

Thanks

New member

Posts

Joined
Sat Nov 22, 2014 12:16 pm

Post by motion2082 » Fri Feb 01, 2019 5:09 pm

This works but it only strips “.00” if you have “.37” or “.04” etc it won’t strip out the decimal. Anyone know how to do that?

Active Member

Posts

Joined
Tue May 12, 2015 8:48 pm

Post by kestas » Fri Feb 01, 2019 6:24 pm

You can use round function to your choice...

Code: Select all

return round($string, 0, PHP_ROUND_HALF_UP);
below examples ho to be rounded if you use some of this functions...

Code: Select all

echo round(9.5, 0, PHP_ROUND_HALF_UP);   // 10
echo round(9.5, 0, PHP_ROUND_HALF_DOWN); // 9
echo round(9.5, 0, PHP_ROUND_HALF_EVEN); // 10
echo round(9.5, 0, PHP_ROUND_HALF_ODD);  // 9

echo round(8.5, 0, PHP_ROUND_HALF_UP);   // 9
echo round(8.5, 0, PHP_ROUND_HALF_DOWN); // 8
echo round(8.5, 0, PHP_ROUND_HALF_EVEN); // 8
echo round(8.5, 0, PHP_ROUND_HALF_ODD);  // 9

Custom OpenCart modules and solutions. You can write PM with additional questions... Extensions you can find here


Active Member

Posts

Joined
Tue Oct 12, 2010 2:23 am

Post by motion2082 » Fri Feb 01, 2019 8:08 pm

kestas wrote:
Fri Feb 01, 2019 6:24 pm
You can use round function to your choice...

Code: Select all

return round($string, 0, PHP_ROUND_HALF_UP);
below examples ho to be rounded if you use some of this functions...

Code: Select all

echo round(9.5, 0, PHP_ROUND_HALF_UP);   // 10
echo round(9.5, 0, PHP_ROUND_HALF_DOWN); // 9
echo round(9.5, 0, PHP_ROUND_HALF_EVEN); // 10
echo round(9.5, 0, PHP_ROUND_HALF_ODD);  // 9

echo round(8.5, 0, PHP_ROUND_HALF_UP);   // 9
echo round(8.5, 0, PHP_ROUND_HALF_DOWN); // 8
echo round(8.5, 0, PHP_ROUND_HALF_EVEN); // 8
echo round(8.5, 0, PHP_ROUND_HALF_ODD);  // 9
Thanks for the tip but that just hides the prices for me

I have a rounding extension installed already

Problem is I can't purchase items without 2 decimals showing with NAB

If I set it to 0 decimals it takes the money but returns a fingerprint mismatch error

Active Member

Posts

Joined
Tue May 12, 2015 8:48 pm
Who is online

Users browsing this forum: Google [Bot] and 46 guests