4

Currently price showing like:

<span class="price">$589.00</span>

i want currency to bit little than other fonts and i should be superlative? like:

<span class="price"><sup>$</sup>589.00</span>

From where do i get that file?

1
  • Did you solve your problem? How? Please share the details with us. Thanks! May 9, 2013 at 7:07

3 Answers 3

3

The currency symbol is defined in /lib/Zend/Locale/Data/_your locale_.xml, but I would not change it there. This will modify it everywhere and at least in pdfs you will get the tags displayed instead of HTML. Simplest way would be to achieve it via the :first-letter css pseudo-selector:

.price:first-letter
{ 
  //style here
}

Browser support is pretty good - http://www.w3schools.com/cssref/sel_firstletter.asp

3
  • Its not working on my site. I have checked above link on Firefox working perfectly but not on my site Apr 1, 2013 at 11:17
  • Are you sure you are writing the proper CSS selector? Apr 1, 2013 at 20:26
  • See .product-view .product-shop .price-box .price:first-letter { font-size: 200% !important; } Apr 3, 2013 at 12:14
1

Looking inside design/frontend/[package]/[theme]/template/catalog/product/price.phtml, it seems all prices are rendered by calling currency(...) inside Mage_Core_Helper_Data

public static function currency($value, $format = true, $includeContainer = true)
{
    return self::currencyByStore($value, null, $format, $includeContainer);
}

currency(...) then calls currencyByStore(...):

public static function currencyByStore($value, $store = null, $format = true, $includeContainer = true)
{
    ...
    $value = $store->convertPrice($value, $format, $includeContainer);
    ...
}

currencyByStore(...) calls convertPrice() inside Mage_Core_Model_Store:

public function convertPrice($price, $format = false, $includeContainer = true)
{
    ...
    if ($this->getCurrentCurrency() && $format) {
        $value = $this->formatPrice($value, $includeContainer);
    }
    return $value;
}

convertPrice(...) calls formatPrice(...):

public function formatPrice($price, $includeContainer = true)
{
    if ($this->getCurrentCurrency()) {
        return $this->getCurrentCurrency()->format($price, array(), $includeContainer);
    }
    return $price;
}

which eventually calls format(...), the format method takes in an options array that gets passed all the way down to Zend_Currency inside /lib/Zend/Currency.php

/**
 * Options array
 *
 * The following options are available
 * 'position'  => Position for the currency sign
 * 'script'    => Script for the output
 * 'format'    => Locale for numeric output
 * 'display'   => Currency detail to show
 * 'precision' => Precision for the currency
 * 'name'      => Name for this currency
 * 'currency'  => 3 lettered international abbreviation
 * 'symbol'    => Currency symbol
 * 'locale'    => Locale for this currency
 * 'value'     => Money value
 * 'service'   => Exchange service to use
 *
 * @var array
 * @see Zend_Locale
 */

Notice the 'symbol' => Currency symbol and:

// Constants for defining what currency symbol should be displayed
const NO_SYMBOL     = 1;
const USE_SYMBOL    = 2;
const USE_SHORTNAME = 3;
const USE_NAME      = 4;

What you can do is override a the currency(), currencyByStore(), convertPrice() and formatPrice() to handle an extra parameter, a new options array and set symbol => 1 from inside price.phtml and then you would be able to do <span class="price"><sup>$</sup>589.00</span>

I haven't tested/tried anything, just followed the function calls so this might not be the best option.

0

Progressive enhancement option: you could target the price block with JS, find the price strings, and adjust the DOM by wrapping the first character with the <sup> tag.

This would give you more layout control in CSS than :first-letter and have roughly equivalent fallback.

1
  • I've used this before, but it's not a general solution. It works only on specific currencies and locale. For some locale the currency symbol contains more than 1 char and it also can be placed after the value. For example: 22.99 RON
    – Marius
    Jan 23, 2014 at 6:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.