tags:

views:

1922

answers:

4

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

as per the code shown when im using $pr->getPrice() its output like 299.0000 but i want like 299.00 how can i do this plz help

+2  A: 

Try number format

"<span style=\"font-size:45px\">{" . number_format($pr->getPrice(), 2) . "}</span>"
Yannick M.
+2  A: 

Use "round" as number format doesn't always work correctly, depending on the location and currency formatting:

<span style=\"font-size:45px\">{" . round($_product->getFinalPrice(),2) . "}</span>
Sam
+1  A: 

or

sprintf("%0.2f",$_product->getFinalPrice());
dan
A: 

i have simple javascript function

var value=100.00000; var result=value.toFixed(2);

alert(result);

result will be 100.00;

Thanks

Naveen