2014-05-01 64 views
2

我正在尝试使用Magento ver创建一个商店。 1.8.1.0。我的编程能力并不好。我是一名电子工程师,只知道嵌入式C。所以,请好好对待我。getPriceHtml函数的返回值包括undefined

我已经从here安装了主题鞋店。这个主题目前运行良好,但我遇到了价格附近的问题,有一个文本“未定义”,因为它可以在下面的截图中看到。

enter image description here

我用我的浏览器来检查这一块的代码,它是这样的:

<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&nbsp;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> 

,并通过new_products.phtml页是一部分生成的HTML代码主题和使用以下内容打印上述HTML代码:

<?php echo $this->getPriceHtml($_product, true) ?> 

As据我了解,“未定义”来自价格的小数部分。我检查了app/design/frontend/base/default/template/catalog/product/price.phtml,但什么都不明白。

我该如何摆脱“未定义”的文字?

+0

这是几乎可以肯定他们相关。交换演示主题,看看问题是否存在。对卖给你主题的人进行处理,可能会存在他们没有告诉你的模块依赖关系。 –

回答

0

感谢Marius,我解决了我的问题。

以下是我的解决方案。我已经改变了部分脚本文件上/app/design/frontend/default/shoe_store/template/page/html/head.phtml如下:

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>'); 
     } 
    }); 

}); 

结果是:

enter image description here