2

I´m working with Prestashop and I´m displaying prices with 4 decimals because I´m accepting EUR and Bitcoins. This is the code where the price is loaded:

<span class="price"><?php echo $product['price']; ?></span>

Is it possible to set the last 2 decimals to display:none?

Marroiak
  • 81
  • 1
  • 11

2 Answers2

3

If you are using Prestashop you should be editing a TPL file. If that's correct you should not use echo inside TPL. You can use this function:

<span class="price">{convertPrice price=$product.price}</span>

Or just use round PHP function and specify decimal precision:

<span class="price">{round($product.price, 2)}</span>

In javascript you can use Math.round() function. More info here: Round 2 decimals JS There is no way to hide decimals partially.

Good luck.

Community
  • 1
  • 1
PrestaAlba
  • 689
  • 4
  • 6
  • Is it a way to do it in javascript? Some function where I can say something like: "Set style="display:none" to the numbers after the second decimal" – Marroiak Jan 06 '17 at 09:42
0

There is a module in PrestaShop Addons, so you can define decimals by currency. For example, you can define 2 decimals for EUR and 4 decimals for Bitcoins.

The link of the module in the Addons :

https://addons.prestashop.com/en/price-management/28731-number-of-decimals-for-price-by-currency.html

mSeed
  • 1