Product display to 4 decimal places

  • Posts: 31
  • Thank you received: 1
  • Hikashop Business
4 years 5 months ago #324333

-- HikaShop version -- : 4.4.0
-- Joomla version -- : 3.9.1
-- PHP version -- : 7.3.21
-- Browser(s) name and version -- : Firefox Developer 82.0b5(64-bit)

Hi

How do I change the unit prices display to show 4 or more decimal places?

Thank you

Neville Matthews

Please Log in or Create an account to join the conversation.

  • Posts: 83407
  • Thank you received: 13498
  • MODERATOR
4 years 5 months ago #324342

Hi,

You can edit the currency via the menu System>Currencies and increase the number of decimals.
Note however that you will be limited by several things:
- the amount of decimals allowed in the database
- the maximum amount of decimals that can be used in PHP calculations
- payment gateways might not like you sending prices with more than 2 decimals

Please Log in or Create an account to join the conversation.

  • Posts: 31
  • Thank you received: 1
  • Hikashop Business
4 years 5 months ago #324432

Hi

I have worked out in the view "listing_price" how I can output product prices to the number of decimal places I want. However are you internal functions documented e.g. :-

Example line from listing_price.php...
echo $this->currencyHelper->format(@$price->price_value, $price->price_currency_id);

This line is at least part of the solution I have worked out using sprintf to output the result I want but I wondered if your functions/methods are documented that I could use in preference to fixing it a bit crudely? This one I am guessing will not be the answer as it is assuming the number of decimal paces from the currency which I don't want to change only the product price display.

Or am I missing something where within the configuration I can change the product price display number of decimal places? I think you have already answered that though.

By the way I am really impressed with the flexibility you have built into this :).


Thanks

Neville Matthews

Please Log in or Create an account to join the conversation.

  • Posts: 83407
  • Thank you received: 13498
  • MODERATOR
4 years 5 months ago #324435

Hi,

Thanks !
Well, as I said you can change that in the settings.
However, if you can do it in the view file it's better because the setting will affect the display everywhere, in the cart, the checkout, the backend etc.
If you just want it different on the listings and products pages. It's better to do an override of listing_price.php
The format function is not documented. But you can't do much with it as you need to pass the currency_id and then it displays the price according to the settings of the currency.
I would have also used sprintf in your case.

Please Log in or Create an account to join the conversation.

Time to create page: 0.057 seconds
Powered by Kunena Forum