I wish to add a simple span class on the product view page for the price.
<span class="price-symbol">$</span>
<span class="price">$99.90</span>
I wish to add a simple span class on the product view page for the price.
<span class="price-symbol">$</span>
<span class="price">$99.90</span>
if you are looking for quick hack then above mentioned method will do the trick. I recommend to override your theme price.phtml and reference handle [catalog_product_view] like below adding your custom price_pdp.phtml in your theme local.xml
Eg:
<catalog_product_view>
<reference name="catalog_product_price_template">
<action method="addPriceBlockType">
<type>simple</type>
<block>catalog/product_price</block>
<template>catalog/product/price_pdp.phtml</template>
</action>
<action method="addPriceBlockType">
<type>configurable</type>
<block>catalog/product_price</block>
<template>catalog/product/price_pdp.phtml</template>
</action>
......
</reference>
</catalog_product_view>
You need to alter the catalog/product/price.phtml
template file, adding the following in several places (for each instance you see of <span class="price">
...):
<span class="price-symbol"><?php echo Mage::app()->getLocale()->currency(Mage::app()->getStore()->getCurrentCurrencyCode())->getSymbol(); ?></span>
This will get the symbol for the currently selected currency.
Pm
Go to this file: Depend upon which theme you are using.
app/design/frontend/custom_theme/default/template/catalog/product/price.phtml
or
app/design/frontend/base/default/template/catalog/product/price.phtml
In magento 2 it can be done by using jquery in phtml file
<?php
$objectManager =\Magento\Framework\App\ObjectManager::getInstance();
$currencysymbol = $objectManager->get('Magento\Store\Model\StoreManagerInterface');
$currency_symbol = $currencysymbol->getStore()->getCurrentCurrencyCode(); ?>
<script>
require(['jquery', 'jquery/ui'], function($){
$('.product-info-price').bind('DOMSubtreeModified', function(){
if($(this).find('.symbol').length == 0) {
$("span.price").each(function() {
$(this).html($(this).html().replace("<?php echo $currency_symbol ?>","<span class='symbol'><?php echo $currency_symbol ?></span>"));
});
}
});
});
</script>