Page 1 of 1

Currency format

Posted: Wed May 16, 2012 1:59 pm
by sw!tch
Is there an opencart function to format currency without the symbol?

I see $this->currency->format($value) , but it includes the currency symbol.

I am using number_format(), but wondering if there was a default OC function for this?

Re: Currency format

Posted: Wed May 16, 2012 3:24 pm
by Avvici
Go to SYSTEM>LOCALISATION>CURRENCIES
If I heard you correctly.,
Just make sure symbol left and symbol right are blank.

Re: Currency format

Posted: Wed May 16, 2012 3:34 pm
by sw!tch
Hi - Thanks for the reply. I am actually writing a API for Opencart, was looking on a code level to do the formatting.

Right now when you do $this->currency->format($value) it returns the currency symbol ($10.00), but I need (10.00) . I was just wondering if OC had a currency function to not include the symbol.

The alternative is PHP's number_format(), but if there is a function would like to keep the code structuring.

Re: Currency format (solved)

Posted: Wed May 16, 2012 3:41 pm
by sw!tch
Actually below seems to work.

Code: Select all

$this->currency->format(10.00,'','',false)

Re: Currency format

Posted: Wed May 16, 2012 3:48 pm
by Avvici
And, that's the way you should call the currency class.

Re: Currency format

Posted: Mon Nov 05, 2012 7:11 pm
by drmrbooster
Hello. I have a problem. My currency format is 18,999.00, but I want this 18.999,00. Can anyone tell me how to fix it? Thanks.

Re: Currency format

Posted: Wed Apr 24, 2013 3:34 pm
by siffrock
Hi,
I have a similar problem passing the values to paypal in UK.
In paypal US it is not a problem but in UK it returns this error:
"The link you have used to enter the PayPal system contains an incorrectly formatted item amount."
the link is this:

Code: Select all

https://www.paypal.com/cgi-bin/webscr?currency_code=GBP&cmd=_cart&upload=1&item_name_1=xxx&amount_1=£45.99&quantity_1=1&
If I remove manually the £ symbol from the link, everything is fine

Code: Select all

https://www.paypal.com/cgi-bin/webscr?currency_code=GBP&cmd=_cart&upload=1&item_name_1=xxx&amount_1=45.99&quantity_1=1&
I think the code to change would be this (I guess):

Code: Select all

'price'    => $this->currency->format($product['price'] + ($this->config->get('config_tax') ? $product['tax'] : 0), $order_info['currency_code'], $order_info['currency_value']),

'total'    => $this->currency->format($product['total'] + ($this->config->get('config_tax') ? ($product['tax'] * $product['quantity']) : 0), $order_info['currency_code'], $order_info['currency_value'])
Any idea where to make the change?

Re: Currency format

Posted: Thu Apr 25, 2013 6:59 am
by Avvici

Re: Currency format

Posted: Thu Apr 25, 2013 1:34 pm
by siffrock
Hi Avvici,
thanks for your reply.
unfortunately there isn't a solution in the link you sent but just the prognosis of the problem that I already knew.
My problem is, what part of the code (above, if this is the right code) I have to change in order to remove the currency symbol?

Re: Currency format

Posted: Wed Jul 17, 2013 11:52 pm
by d3us
First of all, I'm sorry for bumping an old topic, but I'll try to give some answers I couldn't find...
drmrbooster wrote:Hello. I have a problem. My currency format is 18,999.00, but I want this 18.999,00. Can anyone tell me how to fix it? Thanks.
I'm sure that you have already managed to do this, but i search everywhere and no answer to be found...
So for future use I will share my solution:
Go to system/library/currency.php and change code to look like this (line 80)

Code: Select all

if ($format) {
			/*$decimal_point = $this->language->get('decimal_point');*/
			$decimal_point = ',';
		} /*else {
			$decimal_point = ',';
		}*/
		
		if ($format) {
			/*$thousand_point = $this->language->get('thousand_point');*/
			$thousand_point = '.';
		} /*else {
			$thousand_point = '.';
                }*/
I'm using just one language, so this is problem solver for me, but this part of code is to play with.
Of course, you can remove commented parts, but I like to keep code as much original as it is possible, who knows if I'm going to need it in the future...

I guess those changes can be made in each language, but once more - I'm using just one language.


Also, at the line 49 to 57 in this file currency symbols can be removed for good, as requested in first post.

Re: Currency format

Posted: Sat Sep 27, 2014 7:30 am
by frankleng
avvici wrote:Read this
https://www.paypal-community.com/t5/Mer ... anguage=en

Google is a good thing
the reply by paypal says:
This usually happens when you include a currency symbol or a comma in the price.
Can you file a ticket with us at https://www.paypal.com/mts if this is not the case?
----
For technical assistance with PayPal merchant product offerings, please file a ticket at https://www.paypal.com/mts/