php – magento价格getPrice()值

前端之家收集整理的这篇文章主要介绍了php – magento价格getPrice()值前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
function getDescriptionHtml($tpl,$p){
    $out = "";
    $pr = $p["product"];

    if(Mage::getStoreConfig('featuredproducts/displayoptions/title') == 'description'){
        $out .= "<ins><h4>{$pr->getName()}</h4></ins>";
    }
    $out .= "<span class=\"description\"".
            (!Mage::getStoreConfig('featuredproducts/displayoptions/description') ?
                    "style=\"display:none;\""
                :
                    ""
            )
            .">{$p['description']}</span>";
    $out .= "<ins><div>".
            (Mage::getStoreConfig('featuredproducts/displayoptions/price') ?
                    "<span style=\"font-size:45px\">{$pr->getPrice()}</span>"
                :
                    ""
            )       
            ."".
            (Mage::getStoreConfig('featuredproducts/displayoptions/bnb') ?
                    "<div><button style=\"postion:relative;margin-left:80px;margin-top:140px\" class=\"form-button\" onclick=\"setLocation('{$p["url"]}')\"><span>{$tpl->__('Buy Now')}</span></button></div>"
                :
                    "")
            ."
            </div></ins>";
    return $out;        
}

根据显示代码,当我使用$pr-> getPrice()时,其输出看起来像299.0000,但我希望它像299.00.我该怎么做?

尝试 number format
"<span style=\"font-size:45px\">{" . number_format($pr->getPrice(),2) . "}</span>"

猜你在找的PHP相关文章