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.

  • Can you share what you actually wanted to change as this will determine which approach to take? – V.S Aug 13 '16 at 5:29
  • i want to set custom price base 10 based on current price. – Rakesh Jesadiya Aug 16 '16 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. – Rakesh Jesadiya Aug 16 '16 at 12:56
  • @RakeshJesadiya I want to get price after tax including . which file and function return final price with tax included ? – Mukesh Prajapati Jun 4 at 6:45
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>
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.

  • 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? – Rakesh Jesadiya Aug 12 '16 at 16:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.