2

I want to know for Entry point of Product final price calculation, those will be used globally in site like listing page,catalog page, shopping cart page,minicart.

I have to customize for product price, Is there any place we can set price and its used in global.

Where i can find final price of product is set(after special price, catalog/shopping rule if available) in magento 2?

Is there any place where product final price is calculated and its working for magento site Globally in all pages?

Thanks.

4
  • Can you share what you actually wanted to change as this will determine which approach to take? Commented Aug 13, 2016 at 5:29
  • i want to set custom price base 10 based on current price. Commented Aug 16, 2016 at 12:45
  • also i have store with multi currency, in Magento/Catalog/Model/Product/Type/Price.php getPrice function() each time display base price for all currency, i have to find where final price is calculated. Commented Aug 16, 2016 at 12:56
  • @RakeshJesadiya I want to get price after tax including . which file and function return final price with tax included ? Commented Jun 4, 2019 at 6:45

2 Answers 2

2

From my understanding, seem that you want to custom price on your shop. We should see some useful methods for customizing price.

vendor/magento/module-directory/Model/Currency.php

 public function formatPrecision( $price, $precision, $options = [], $includeContainer = true, $addBrackets = false ) { ...... } 

vendor/magento/module-directory/Model/PriceCurrency.php

 public function format( $amount, $includeContainer = true, $precision = self::DEFAULT_PRECISION, $scope = null, $currency = null ) { ...... } public function convertAndRound($amount, $scope = null, $currency = null, $precision = self::DEFAULT_PRECISION) { ...... } 

vendor/magento/framework/Locale/Format.php

 public function getPriceFormat($localeCode = null, $currencyCode = null) { ...... } 

For sample di.xml:

<?xml version="1.0"?> <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd"> <type name="Magento\Directory\Model\Currency"> <plugin name="modify_around_precision" type="Vendor\YourModule\Model\Directory\Plugin\Precision" /> </type> <type name="Magento\Directory\Model\PriceCurrency"> <plugin name="modify_around_format" type="Vendor\YourModule\Model\Directory\Plugin\Format" /> <plugin name="modify_around_round" type="Vendor\YourModule\Model\Directory\Plugin\PriceRound" /> </type> <type name="Magento\Framework\Locale\Format"> <plugin name="modify_around_price_format" type="Vendor\YourModule\Model\Locale\Plugin\ModifyPriceFormat" /> </type> </config> 
3
  • 1
    There is a good sample here: github.com/Magento-Japan/m2-jplocalize/tree/master/price Commented Aug 13, 2016 at 4:42
  • i have store with multi currency, in Magento/Catalog/Model/Product/Type/Price.php getPrice function() each time display base price for all currency, i have to find where final price is calculated. Commented Aug 16, 2016 at 12:57
  • @KhoaTruongDinh wouldn't it be better to use Currency.php instead of Precision.php? Commented Sep 26, 2016 at 16:53
1

If you're looking for the template that renders the final price of products, then bringing this (magento2/app/code/Magento/Catalog/view/base/templates/product/price/final_price.phtml) file to your theme should do the job.

And this file (magento2/app/code/Magento/Catalog/Model/Product/Type/Price.php) is probably where the final price is calculated.

Hope this helps.

1
  • If we here change price of product then its automatically set whole site, if i am change price from model file, its same display in cart page also? Commented Aug 12, 2016 at 16:53

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.