2014-05-01 63 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