Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Currency Symbol Right - Space and Styling


douglaswalker

Recommended Posts

Hi there

Interesting issue

I use the symbol right in currencies to show the currency $0.00 AUD.

If you dont place   before the AUD when it is inputted into the box in Admin you get this $0.00AUD

However if you do use   then it shows up in admin on the PayPal balance with the new APP... no where else though.. emails work fine etc.

 

The other question is this

The AUD is the same text size as the price I would like it to be <small></small>

How could i go about this without breaking anything.

Doug

 

Link to comment
Share on other sites

Hello Doug @douglaswalker,

 

You can do this in the currencies class within the format function. Use a normal space and it will show well on all places.

rgds

Rainer

Link to comment
Share on other sites

if ($calculate_currency_value == true) {
        $rate = (tep_not_null($currency_value)) ? $currency_value : $this->currencies[$currency_type]['value'];
        $format_string = $this->currencies[$currency_type]['symbol_left'] . number_format(tep_round($number * $rate, $this->currencies[$currency_type]['decimal_places']), $this->currencies[$currency_type]['decimal_places'], $this->currencies[$currency_type]['decimal_point'], $this->currencies[$currency_type]['thousands_point']) . ' <small>'.  $this->currencies[$currency_type]['symbol_right'].'</small>';
      } else {
        $format_string = $this->currencies[$currency_type]['symbol_left'] . number_format(tep_round($number, $this->currencies[$currency_type]['decimal_places']), $this->currencies[$currency_type]['decimal_places'], $this->currencies[$currency_type]['decimal_point'], $this->currencies[$currency_type]['thousands_point']) .' <small>'. $this->currencies[$currency_type]['symbol_right'].'</small>';
      }

      return $format_string;
    }

So like the above? I  added .' <small>'.  and .'</small>' at the end.

It works on the site i was just concerned it may case issues somewhere I don't know about. i don't want to pass the space and <small> to any payment gateways.

Link to comment
Share on other sites

Yes, this does work, I use it also on a live shop. The payment modules do not use the formatted output to pass to gateways. The formatted output is only used for display purposes.

Link to comment
Share on other sites

Should work too, html tags are stripped off for non html mails, just try.

Link to comment
Share on other sites

Be careful about replacing &nbsp; with a regular space. If your price is near the end of a line, the browser might try to word wrap and end up splitting the price between the number and the "AUD". The whole point of a &nbsp; is to always keep all the text together. Regarding non-HTML emails and payment gateways, someone will need to experiment (and read the docs) to see if additional processing is needed to remove or change entities (like &nbsp;) and strip HTML tags (like <small>) before sending it off. A payment gateway might be expecting a very specific format for currencies.

Link to comment
Share on other sites

@MrPhil,

for &nbsp;, ok as he already uses another html tag, he can also use it here, it doesn't matter then. I just thought if it's the only mod then it will be sure, using normal space will avoid to appear any undesired html tag anywhere. It's unlike that just the currency symbol will break into a new line.

For the payment gateways: I did a fast search  through the actual core payment modules and any of them uses neither the format nor the display_price function. They all use the display_raw or format_raw functions to pass prices to the gateway. The display_price function is only used to create the e-mail order confirmation.

However as we can not exclude that an older or third party payment module may use them, as always, before to apply a sensitive mod like this, it should be tested.

Link to comment
Share on other sites

HTML entities and HTML tags (elements) are two different things. The mechanisms for stripping them out or removing them are different, and both may or may not be implemented in osC code. So just use caution if you have anything other than plain text, and test to make sure your non-plain-text is properly handled.

Link to comment
Share on other sites

@MrPhil,

yep, you are right. I mixed up something. In the "tep_mail function", "strip_tags" is used for plain text mails, so the html entities will not be converted.

A reason to use normal space instead of &nbsp;. I know that I remembered something that it can produce problems using html entities.

 

rgds

Rainer

Link to comment
Share on other sites

Hi there

had a few interesting issues with this

using  space<small>AUD</small> does cause the line to break sometimes so you get AUD below the price.

i just went with <small>AUD</small> no space... which to me looks fine with no space and the smaller AUD.

i had no issue with email either HTML or Plain.

The only issue i had was where something had been coded incorrectly and the display method had been used but that was not stock Oscommerce.

 

There was also an issue in account_history with the price squashed up in a <td> that was to small for it with the AUD added  but i expect that is a bug that must effect all shops that show AUD or similar. 

So all in all it works.

 

 

Link to comment
Share on other sites

if ($calculate_currency_value == true) {
        $rate = (tep_not_null($currency_value)) ? $currency_value : $this->currencies[$currency_type]['value'];
        $format_string = $this->currencies[$currency_type]['symbol_left'] .'<span style="white-space: nowrap;">'. number_format(tep_round($number * $rate, $this->currencies[$currency_type]['decimal_places']), $this->currencies[$currency_type]['decimal_places'], $this->currencies[$currency_type]['decimal_point'], $this->currencies[$currency_type]['thousands_point']) .'<small style="padding-left: 5px;">'. $this->currencies[$currency_type]['symbol_right'].'</small>';
      } else {
        $format_string = $this->currencies[$currency_type]['symbol_left'] .'<span style="white-space: nowrap;">'. number_format(tep_round($number, $this->currencies[$currency_type]['decimal_places']), $this->currencies[$currency_type]['decimal_places'], $this->currencies[$currency_type]['decimal_point'], $this->currencies[$currency_type]['thousands_point']) .'<small style="padding-left: 5px;">'. $this->currencies[$currency_type]['symbol_right'].'</small>';
      }

      return $format_string;
    }

So for anyone reading this. This is what I have

perfect thank-you:thumbsup:

Link to comment
Share on other sites

  • 3 weeks later...

The following works for me nice for symbol left and symbol right currencies and maintaining the original size:

    			$format_string = '<span style="padding-right: 5px;">' . $this->currencies[$currency_type]['symbol_left'] . '</span>' . number_format(tep_round($number * $rate, $this->currencies[$currency_type]['decimal_places']), $this->currencies[$currency_type]['decimal_places'], $this->currencies[$currency_type]['decimal_point'], $this->currencies[$currency_type]['thousands_point']) . '<span style="padding-left: 5px;">' . $this->currencies[$currency_type]['symbol_right'] . '<span>';
    		} else {
    			$format_string = '<span style="padding-right: 5px;">' . $this->currencies[$currency_type]['symbol_left'] . '</span>' . number_format(tep_round($number, $this->currencies[$currency_type]['decimal_places']), $this->currencies[$currency_type]['decimal_places'], $this->currencies[$currency_type]['decimal_point'], $this->currencies[$currency_type]['thousands_point']) . '<span style="padding-left: 5px;">' . $this->currencies[$currency_type]['symbol_right'] . '<span>';

 

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...