Jan 9, 2014

Posted by in Magento | 0 comments

How to use getPriceHtml function in Magento to display custom price as value

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

getPriceHtml function in Magento is generally used to display price in a specific format, the above function will always display the price associated with the product.

However if you would like to display a value as price using the same HTML than you can use the following code.

<?php
    //Here $_product is the Product Collection Object
    $custom_price = '4.99';
    $_product->setCustomPrice($custom_price);
    echo $this->getPriceHtml($_product, true);
?>

Leave a Reply