0
votes

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.

2
It's the same file, just try not to get lost in the if-else statements. There should be a case for the price without additional textsMarius
"It's the same file, just try not to get lost in the if-else statements." It's totally possible that this is what's happening. It's been frustrating.Sean
I would do it the quick and dirty way...Javascript. Find a common selector for your prices and use that to add the textMarius
I've been cautioned to not take shortcuts here as magento is...touchy. I've been searching through the price.phtml file and I'm not finding a case that covers the default displaying of the price, What am I missing? Each of the cases in that file covers special cases with html ids that are not appearing on the front end. I'm confused to say the least.Sean

2 Answers

1
votes

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; ?>
0
votes

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