About Club osCommerce

Showcasing osCommerce…the good, the bad and the ugly!

StumbleUpon It! DIGG It!

Display Price in two different sizes?

Written By Gary on Jun 01 2009 · Comments (0)

Buy Gary A Beer?
Buying me a "beer" helps me to keep my contributions updated and keep this blog alive - and you get a link from my homepage to your site. Cheers!


At the official osCommerce forum, Matt asked;

How can I get the prices to display with two different sized fonts ie $129.95

You can plainly see that he is trying to show the cents in a different way than the dollars. This is very easy to accomplish;

Open up /includes/classes/currencies.php

Find:

PHP:
  1. if ($calculate_currency_value == true) {
  2.         $rate = (tep_not_null($currency_value)) ? $currency_value : $this->currencies[$currency_type]['value'];
  3.         $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']) . $this->currencies[$currency_type]['symbol_right'];
  4.       } else {
  5.         $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']) . $this->currencies[$currency_type]['symbol_right'];
  6.       }

Change to:

PHP:
  1. if ($calculate_currency_value == true) {
  2.         $rate = (tep_not_null($currency_value)) ? $currency_value : $this->currencies[$currency_type]['value'];
  3.         $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']) . $this->currencies[$currency_type]['symbol_right'];
  4.         $format_string = explode($this->currencies[$currency_type]['decimal_point'], $format_string);
  5.         $format_string = $format_string[0] . $this->currencies[$currency_type]['decimal_point'] . '<sup>' . $format_string[1] . '</sup>';
  6.       } else {
  7.         $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']) . $this->currencies[$currency_type]['symbol_right'];
  8.         $format_string = explode($this->currencies[$currency_type]['decimal_point'], $format_string);
  9.         $format_string = $format_string[0] . $this->currencies[$currency_type]['decimal_point'] . '<sup>' . $format_string[1] . '</sup>';
  10.       }

You can style the "sup" appropriately using css, this would be done in the stylesheet.css file.

Easy as 123.

No Comments

No comments yet.

Leave a comment

RSS feed for comments on this post · TrackBack URL

Hot 100 osCommerce Shops

View the osCommerce HOT 100These are the best looking, most exceptional osCommerce Stores as voted for by you.

New to osCommerce - get inspiration from these beautiful shops. Reckon your site has what it takes to become a member of the HOT 100? Submit it!