Help locating a file in Magento that contains HTML

Alexander: 2 weeks ago

I'm trying to change the class name in the HTML output from "price". I was hoping to find it in the code block below.

The following code (frontend/default/theme/template/page/html/cart.phtml):

<div class="shopping_cart_b">
    <a href="#" class="open">
        <?php echo $this->__('Shopping Cart:'); ?>
        <?php echo $_cartQty; ?> <span><?php echo $this->__('Item(s) - '); ?></span>

        <?php if ($this->canApplyMsrp()): ?>
            <?php echo $this->__('ORDER TOTAL WILL BE DISPLAYED BEFORE YOU SUBMIT THE ORDER'); ?>
        <?php else: ?>
            <?php echo Mage::helper('checkout')->formatPrice($this->getSubtotal()) ?>
            <?php if ($_subtotalInclTax = $this->getSubtotalInclTax()): ?>
                (<?php echo Mage::helper('checkout')->formatPrice($_subtotalInclTax) ?> <?php echo Mage::helper('tax')->getIncExcText(true) ?>)
            <?php endif; ?>
        <?php endif; ?>


Produces the following output (in Header):

<div class="shopping_cart_b">
    <a href="#" class="open">
        Shopping Cart: 
            <span>Item(s) - </span>
            <span class="price">£0.00</span>                                     

Block Name Hint:


I've determined that <?php echo Mage::helper('checkout')->formatPrice($this->getSubtotal()) ?> is responsible for calling <span class="price">£0.00</span>, but I've no idea where to find the actual file to change the CSS class.

I've used grep to try and find the file, but there are too many results. Any help appreciated.

Brielle: 2 weeks ago

What you are looking for is something that you won't find in a phtml file. The magento helper function has a second parameter that is by default, set true. The parameter, I believe is whether to include the container or not. The container, if my memory is correct, is where html is being included and perhaps the class name is within the code. I strongly suggest NOT updating the code, but rather apply a second parameter of false and see what sort of output you can then work with. If what I say is correct, it should be simply the price. Therefore, try this as a solution:

<span class="price price-customclass"><?php echo Mage::helper('checkout')->formatPrice($this->getSubtotal(), false) ?></span>

I strongly suggest to append your new class name, instead of replacing the original. Keeping the original class name price would be helpful to ensure that anything referencing or depending on that class is not affected.


The code above is incorrectly assumed, but ultimately correct if you trace the function calls. The call I have in the code snippet actually doesn't allow for a second parameter. Tracing call hierarchy reveals that you may substitute that code with:

Mage::getSingleton('checkout/session')->getQuote()->getStore()->formatPrice($price, false);


As I had suggested above, the class name is, in fact, applied by code not found within a template file. The code below was found within: magento/app/code/core/Mage/Directory/Model/Currency.php

   if ($includeContainer) {
            return '<span class="price">' . ($addBrackets ? '[' : '') . $this->formatTxt($price, $options) .
                ($addBrackets ? ']' : '') . '</span>';