How can I get access to modify this price function

2019-09-04 01:59发布

问题:

So I now need to customize the discounted price for my Shopping cart. I'd research it by myself and I realize i can modify the view.phtml and item.phtml in order to display the right price. But i am not satisfied, therefore my eyes on this line of code:

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

I presume this line of code's function is to call the price from somewhere call checkout in helper section and return it. My question is how can i get access to there.

Thank you so much.

UPDATE 1: I did some research after aton gave me some tips then i dive into the file DATA.php and found the function he mentioned which is:

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

But is there any way to dive even deeper into $this->getQuote()->getStore()->formatPrice($price);

Once again thanks.

回答1:

In the code you have mentioned above the price is coming from $_item->getCalculationPrice().

The code

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

just takes the price and formats it i.e adds the currency symbol according to your store and other things.

If you want to know where is the formatPrice function resides navigate to

app/code/core/Mage/checkout/Helper/Data.php

Here you will see the defination of that function.

Hope this will help.