Post by sw!tch » Wed May 16, 2012 1:59 pm

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?

Full Stack Web Developer :: Send a PM for Custom Work.
Backup and learn how to recover before you make any changes!


Active Member

Posts

Joined
Sat Apr 28, 2012 2:32 pm

Post by Avvici » Wed May 16, 2012 3:24 pm

Go to SYSTEM>LOCALISATION>CURRENCIES
If I heard you correctly.,
Just make sure symbol left and symbol right are blank.

User avatar
Expert Member

Posts

Joined
Tue Apr 05, 2011 12:09 pm
Location - Asheville, NC

Post by sw!tch » Wed May 16, 2012 3:34 pm

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.

Full Stack Web Developer :: Send a PM for Custom Work.
Backup and learn how to recover before you make any changes!


Active Member

Posts

Joined
Sat Apr 28, 2012 2:32 pm

Post by sw!tch » Wed May 16, 2012 3:41 pm

Actually below seems to work.

Code: Select all

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

Full Stack Web Developer :: Send a PM for Custom Work.
Backup and learn how to recover before you make any changes!


Active Member

Posts

Joined
Sat Apr 28, 2012 2:32 pm

Post by Avvici » Wed May 16, 2012 3:48 pm

And, that's the way you should call the currency class.

User avatar
Expert Member

Posts

Joined
Tue Apr 05, 2011 12:09 pm
Location - Asheville, NC

Post by drmrbooster » Mon Nov 05, 2012 7:11 pm

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.

Newbie

Posts

Joined
Sun Oct 28, 2012 7:58 pm

Post by siffrock » Wed Apr 24, 2013 3:34 pm

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?

Newbie

Posts

Joined
Fri Oct 28, 2011 11:24 pm
Location - London

Post by Avvici » Thu Apr 25, 2013 6:59 am


User avatar
Expert Member

Posts

Joined
Tue Apr 05, 2011 12:09 pm
Location - Asheville, NC

Post by siffrock » Thu Apr 25, 2013 1:34 pm

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?

Newbie

Posts

Joined
Fri Oct 28, 2011 11:24 pm
Location - London

Post by d3us » Wed Jul 17, 2013 11:52 pm

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.

Newbie

Posts

Joined
Thu Oct 25, 2012 9:58 am

Post by frankleng » Sat Sep 27, 2014 7:30 am

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/

Active Member

Posts

Joined
Sun Apr 22, 2012 5:49 pm
Who is online

Users browsing this forum: No registered users and 126 guests