I am trying to create a store using Magento ver. 1.8.1.0. My programming capabilities are not great. I am an electronics engineer and I know embedded C properly, only. So, please treat me well.
I have installed the theme Shoes Store from here. The theme works fine for now, but I have ran into the problem that near the price, there is a text "undefined", as it can be seen in the below screenshot clip.
I have used my browser to check the code of this block and it is like this:
<div class="price-box">
<span class="regular-price" id="product-price-1">
<span class="price">
<span class="cur_sym">1</span>
<span class="price_int">9,99 TL.</span>
<span class="price_deci">undefined</span></span>
</span>
</div>
<div class="actions">
<a class="details" href="http://www.myurl.com/store/denek-urun.html" title="Details">Details</a>
</div>
And this HTML code is generated by new_products.phtml page which is a part of the theme and which uses following to print the above HTML code:
<?php echo $this->getPriceHtml($_product, true) ?>
As far as I understand, the "undefined" comes from the decimal part of the price. I have checked app/design/frontend/base/default/template/catalog/product/price.phtml
but couldn't understand anything.
How can I get rid of the "undefined" text?
Thanks to Marius, I have solved my problem.
Below is my solution. I have changed the script part on file /app/design/frontend/default/shoe_store/template/page/html/head.phtml
as follows:
var price, sepstr, firstpart, secondpart, currency;
jQuery(document).ready(function ()
{
jQuery(
'.newproducts .price-box .regular-price .price, .newproducts .old-price .price, .newproducts .special-price .price, .category-products .price-box .regular-price .price, .category-products .old-price .price, .category-products .special-price .price, .product-shop .price-box .regular-price .price, .product-shop .old-price .price, .product-shop .special-price .price'
).each(function ()
{
price = jQuery.trim(jQuery(this).text());
if(price.indexOf("TL") > -1) // The currency is TL
{
sepstr = price.split(',');
firstpart = sepstr[0];
secondpart = sepstr[1];
currency = secondpart[3] + secondpart[4];
secondpart = secondpart.replace(currency, '');
jQuery(this).html('<span class="price_int">' + firstpart +
',</span><span class="price_deci">' + secondpart + '</span>' + '<span class="price_int">' + currency + '</span>');
}
else
{
sepstr = price.split('.');
firstpart = sepstr[0];
secondpart = sepstr[1];
currency = firstpart[0];
firstpart = firstpart.replace(currency, '');
jQuery(this).html('<span class="cur_sym">' + currency + '</span><span class="price_int">' + firstpart +
'.</span><span class="price_deci">' + secondpart + '</span>');
}
});
});
The result is: