user1958112
user1958112

Reputation: 65

Remove <span class="price"> tag from formatPrice

how can I remove/turn off <span class="price">...</span> from

<?php echo $this->helper('checkout')->formatPrice($_item->getCalculationPrice()) ?>

in

 <?php echo $_coreHelper->currency($_finalPrice, true, false) ?>

i was change last argument to false and price print without <span class="price">...</span> so I wonder how can I do in

<?php echo $this->helper('checkout')->formatPrice($_item->getCalculationPrice()) ?>

I dont want change core file. Thx for help.

Upvotes: 1

Views: 4655

Answers (3)

PICher
PICher

Reputation: 101

In Magento, when using

Mage::helper('checkout')->formatPrice($price);

to get $price in local format, it prints $price which is enclosed by <span class=”price”></span>. In some case, this is not very pratical. If you don’t like this <span> tag much, you can use this method:

Mage::helper('checkout')->getQuote()->getStore()->formatPrice($price, false);

http://ntuan16.wordpress.com/2011/12/20/how-to-use-formatprice-without-tag/

Upvotes: 0

Richard Feraro
Richard Feraro

Reputation: 477

Just use strip_tags() in PHP instead.

Upvotes: 7

dagfr
dagfr

Reputation: 2384

You have to rewrite the Checkout Helper (Data.php) to your Namespace, to overwrite this function :

public function formatPrice($price)
{
    return $this->getQuote()->getStore()->formatPrice($price);
}

replace it with

public function formatPrice($price,$includeContainer = false)
{
    return $this->getQuote()->getStore()->formatPrice($price,$includeContainer);
}

Then you'll just need this :

<?php echo $this->helper('checkout')->formatPrice($_item->getCalculationPrice()) ?

to Hide the span and :

<?php echo $this->helper('checkout')->formatPrice($_item->getCalculationPrice(),true) ?

to get it back.

Upvotes: 0

Related Questions