Skip to main content

Price: Hide currency code and not show decimals

More
13 years 1 month ago - 13 years 1 month ago #120602 by cipionhabla
-- HikaShop version -- : 2.2.0
-- Joomla version -- : 3.1.5
-- PHP version -- : 5.3.27

Hi,

Is there a way in the product price to hide the currency code and not show decimal numbers?

Regards
Last edit: 13 years 1 month ago by cipionhabla.

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

More
13 years 1 month ago #120622 by Eliot
Hi there,

To do so you have to edit the view listing_price of product (Display>Views).
You will find there the html and php code used to display the price so you can add a round() on a price to not display the decimal and you can delete the currency code by using directly:
Code:
$price->price_orig_value_with_tax
instead of:
Code:
echo $this->currencyHelper->format($price->price_orig_value_with_tax,$price->price_orig_currency_id);

(this is an example, it may be a different line according to the way you display your prices)

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

More
12 years 2 months ago #163504 by denoo
Hi,

I've tried this.
Result: 13,00 € -> 13.00000
What do I have to add to "echo $price->price_value_with_tax;" or delete from "echo $this->currencyHelper->format(@$price->price_value_with_tax,$price->price_currency_id);" to hide only currency code?

Thanks in advance.

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

More
12 years 2 months ago #163514 by Xavier
Hi,

You can simply change the settings via the menu System > Currencies.

Or edit:
Code:
echo $this->currencyHelper->format(@$price->price_value_with_tax,$price->price_currency_id);
To add a '!' as third parameter, like:
Code:
echo $this->currencyHelper->format(@$price->price_value_with_tax,$price->price_currency_id,'!');

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

More
12 years 2 months ago - 12 years 2 months ago #163635 by denoo
Hi, Xavier

thank you. The second solution better suits my needs, because I want to hide currency code only in a certain part of my web. But when I have added '!' as third parameter, I got the price looking like " !".

UPD: Now I see that I can't hide currency code in a particular part of the web, directly editing listing_price...
I want to hide currency code in listing table.
Last edit: 12 years 2 months ago by denoo.

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

More
12 years 2 months ago - 12 years 2 months ago #163639 by Xavier
Hi,

Indeed, so another solution is just to use the str_replace php function like:
Code:
$curr = ''; $currencyInfo = $this->currencyHelper->getCurrencies($price->price_currency_id,$curr); echo str_replace(array($currencyInfo[1]->currency_symbol,$currencyInfo[1]->currency_code),'',$this->currencyHelper->format(@$price->price_value_with_tax,$price->price_currency_id));
Last edit: 12 years 2 months ago by Jerome. Reason: improve code
The following user(s) said Thank You: denoo

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

More
12 years 2 months ago #163820 by denoo
Hi,

amatuer question: where it must be pasted?
I figure that it must be pasted directly in listing_table instead of loading listing_price template, so:
Code:
<?php if($this->params->get('show_price','-1')=='-1'){ $config =& hikashop_config(); $this->params->set('show_price',$config->get('show_price')); } if($this->params->get('show_price')){ ?> <td class="hikashop_product_price_row"> <?php //$this->setLayout('listing_price'); //echo $this->loadTemplate(); $currencyClass = hikashop_get('class.currency'); $curr = ''; $currencyInfo = $currencyClass->getCurrencies($price->price_currency_id,$curr); echo str_replace(array($currencyInfo[1]->currency_symbol,$currencyInfo[1]->currency_code),'',$this->currencyHelper->format(@$price->price_value_with_tax,$price->price_currency_id)); ?> </td> <?php } ?>

But the result is "0,00 €" for all prices. Perhaps I did an obvious mistake, but I can not figure it out.

Thank you.

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

More
12 years 2 months ago #163823 by Jerome
Hi,

Xavier gave you some for the same view (same line) than the previous post : listing_price.

Regards,

Jerome - Obsidev.com
HikaMarket & HikaSerial developer / HikaShop core dev team.

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

More
12 years 2 months ago #163865 by denoo
Hi, Jerome

When I add this code to listing_price than currency code is hidden everywhere (I can achieve it, as Xavier said, setting via the menu System > Currencies ). But I want it to be hidden only in the product listing table.
If there is a simple solution, I'm gonna find it. If it's complicated I'm gonna hide currency code via the menu System > Currencies and add it where it is needed (for example CART) using language variable.

Thanks
Denis

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

More
12 years 2 months ago #163869 by Jerome
Hi,

So I will suggest you to make some text replacement in the view listing_table.
Instead of
Code:
$this->setLayout('listing_price'); echo $this->loadTemplate();
You can get the content and modify it, like this example:
Code:
$this->setLayout('listing_price'); $currentyData = $this->loadTemplate(); echo str_replace('$', '', $currentyData);
Regards,

Jerome - Obsidev.com
HikaMarket & HikaSerial developer / HikaShop core dev team.
The following user(s) said Thank You: denoo

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

More
12 years 2 months ago #163933 by denoo
Hi, Jerome

that's it. In my case it was "€", so I just changed it in your example. Now I know how to use str_replace in such cases, so in future I'll use it.

Thank you for your product and support.
Denis

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

Time to create page: 0.242 seconds
Powered by Kunena Forum