Add Text Before Price in Magento 1.8.1
on February 12, 2014
Sometimes it is necessary to add descriptive text in front of the price display in Magento. For instance, you may be selling something priced per unit, such as flooring by the square foot or fabric by the yard. Luckily, this is a quick and easy edit, just follow the steps below. While optimized for Magento 1.8.1, the below steps should work on earlier versions. However, line references may be slightly different:
1) Open app/design/frontend/YOUR_PACKAGE/YOUR_THEME/template/catalog/product/price.phtml.
If you have not yet created an override file for your theme, you can copy the file from \app\design\frontend\base\default\template\catalog\product\price.phtml
.
2) At line 206, locate the below block of code:
<?php else: ?> <span class="regular-price" id="product-price-<?php echo $_id ?><?php echo $this->getIdSuffix() ?>"> <?php if ($_finalPrice == $_price): ?> <?php echo $_coreHelper->formatPrice($_price, true) ?> <?php else: ?> <?php echo $_coreHelper->formatPrice($_finalPrice, true) ?> <?php endif; ?>
3) Add the below code on line 207 right below <?php else: ?>
<span class="NAME_YOUR_SPAN"><?php echo $this->__("CUSTOM TEXT") ?></span>
4) Your updated code should look like:
<?php else: ?> <span class="NAME_YOUR_SPAN"><?php echo $this->__("CUSTOM TEXT") ?></span> <span class="regular-price" id="product-price-<?php echo $_id ?><?php echo $this->getIdSuffix() ?>"> <?php if ($_finalPrice == $_price): ?> <?php echo $_coreHelper->formatPrice($_price, true) ?> <?php else: ?> <?php echo $_coreHelper->formatPrice($_finalPrice, true) ?> <?php endif; ?>
All done! Your custom text will be displayed before the price in both the catalog and the product pages. If you only wish to display the custom text in one location, use CSS to hide span .NAME_YOUR_SPAN
in the appropriate location.
Thanks Sir! You saved me a lot of time 🙂
Works greaty, thanks.
But how can I hide my custom text before the price, when all custom options are selected?
[…] tried to follow this tutorial:https://www.collaboration133.com/add-text-before-price-in-magento-1-8-1/2746/ but it doesn’t work. I’ve tried ET Currency Manager extension, it’s work but in […]
This works great thanks.
I am looking for a way to put from only in front of my configured products. Please could you let me know how you would go about this?
Thanks in advance 🙂
Philippa, you could probably use CSS to accomplish this by hiding the custom span on non-configurable product pages. Or you could locate the .phtml file that corresponds to the configurable product view and edit it there.
does this also work on version 1.9.1.0? If not please advise as my web developer is a dodo!
Hi, can someone please advise. I am also wanting to add text before price e.g- From £3.99 and need to know if the above will work with 1.9.1.0? My wed developer is a dodo and can’t do anything on magento! really appreciate any replies thanks.
thank you for great article! I want to display you save like amazon price display.how can i do this?