Sean
Sean

Reputation: 57

add string to displayed price in magento

I'm trying to add a simple string to the display price in Magento. Currently the price displays as $##.## by default. I would like it to read: Price: $##.##

A simple search of the displayed prices brought me to template/catalog/product/price.phtml. This file seems to control price display when there are variables involved. IE, price including tax, excluding tax, special prices, etc...

Which file is controlling the displayed price when there are no variables involved, the default price:

<span class="price">$##.##</span>

Once I figure out where this is located, I'm confident I can append a simple string before the displayed price.

Thanks in advance.

Upvotes: 0

Views: 1361

Answers (2)

manu
manu

Reputation: 82

i'm on magento 1.8, and developing on nearly plain system, when debugging, i'm on

                 <?php if ($_finalPrice == $_price): ?>
                    <?php echo $_coreHelper->currency($_price, true, true) ?>
                <?php else: ?>
                    <?php echo $_coreHelper->currency($_finalPrice, true, true) ?>
                <?php endif; ?>

round about line 201

Upvotes: 0

Marius
Marius

Reputation: 15216

OK. I was suggesting in the comments not to get lost in the if-else statements but I just did also for a few minutes. Finally found it.
Inside this if statement

<?php if ($_finalPrice >= $_price): ?>

there is an other if:

<?php if ($_taxHelper->displayBothPrices()): ?>

On the else statement of this last if there is the part you are looking for.

            <?php if ($_weeeTaxAmount && $_weeeHelper->typeOfDisplay($_product, 0)): // including ?>
                <span class="regular-price" id="product-price-<?php echo $_id ?><?php echo $this->getIdSuffix() ?>">
                    <?php echo $_coreHelper->currency($_price + $_weeeTaxAmount, true, true) ?>
                </span>
            <?php elseif ($_weeeTaxAmount && $_weeeHelper->typeOfDisplay($_product, 1)): // incl. + weee ?>
                <span class="regular-price" id="product-price-<?php echo $_id ?><?php echo $this->getIdSuffix() ?>">
                    <?php echo $_coreHelper->currency($_price + $_weeeTaxAmount, true, true) ?>
                </span>
                <span class="weee">(
                    <?php foreach ($_weeeTaxAttributes as $_weeeTaxAttribute): ?>
                        <?php echo $_weeeSeparator; ?>
                        <?php echo $_weeeTaxAttribute->getName(); ?>: <?php echo $_coreHelper->currency($_weeeTaxAttribute->getAmount(), true, true); ?>
                        <?php $_weeeSeparator = ' + '; ?>
                    <?php endforeach; ?>
                    )</span>
            <?php elseif ($_weeeTaxAmount && $_weeeHelper->typeOfDisplay($_product, 4)): // incl. + weee ?>
                <span class="regular-price" id="product-price-<?php echo $_id ?><?php echo $this->getIdSuffix() ?>">
                    <?php echo $_coreHelper->currency($_price + $_weeeTaxAmount, true, true) ?>
                </span>
                <span class="weee">(
                    <?php foreach ($_weeeTaxAttributes as $_weeeTaxAttribute): ?>
                        <?php echo $_weeeSeparator; ?>
                        <?php echo $_weeeTaxAttribute->getName(); ?>: <?php echo $_coreHelper->currency($_weeeTaxAttribute->getAmount() + $_weeeTaxAttribute->getTaxAmount(), true, true); ?>
                        <?php $_weeeSeparator = ' + '; ?>
                    <?php endforeach; ?>
                    )</span>
            <?php elseif ($_weeeTaxAmount && $_weeeHelper->typeOfDisplay($_product, 2)): // excl. + weee + final ?>
                <span class="regular-price"><?php echo $_coreHelper->currency($_price,true,true) ?></span><br />
                <?php foreach ($_weeeTaxAttributes as $_weeeTaxAttribute): ?>
                    <span class="weee">
                        <?php echo $_weeeTaxAttribute->getName(); ?>: <?php echo $_coreHelper->currency($_weeeTaxAttribute->getAmount(), true, true); ?>
                    </span>
                <?php endforeach; ?>
                <span class="regular-price" id="product-price-<?php echo $_id ?><?php echo $this->getIdSuffix() ?>">
                    <?php echo $_coreHelper->currency($_price + $_weeeTaxAmount, true, true) ?>
                </span>
            <?php else: ?>
                <span class="regular-price" id="product-price-<?php echo $_id ?><?php echo $this->getIdSuffix() ?>">
                    <?php if ($_finalPrice == $_price): ?>
                        <?php echo $_coreHelper->currency($_price, true, true) ?>
                    <?php else: ?>
                        <?php echo $_coreHelper->currency($_finalPrice, true, true) ?>
                    <?php endif; ?>
                </span>
            <?php endif; ?>

Each part in this code shows a regular price, depending on the tax settings. Most probably you need only the last part.

<?php if ($_finalPrice == $_price): ?>
    <?php echo $_coreHelper->currency($_price, true, true) ?>
<?php else: ?>
    <?php echo $_coreHelper->currency($_finalPrice, true, true) ?>
<?php endif; ?>

Upvotes: 1

Related Questions