Here is my question - How to show prices for all out of stock products? 
Here pic http://prntscr.com/krhurk

I created the module from here https://magento.stackexchange.com/questions/160145/magento-2-how-to-show-prices-for-out-of-stock-products
enabled but still, nothing :/ any suggest? Version Magento 2.2.5

    You need to create your custom module using below code

Let say module name Custom_Outofstock

So create folder in app/code

Create registration.php file at app/code/Custom/Outofstock/registration.php

Add blow code to it



Create module.xml at app/code/Custom/Outofstock/etc/module.xml

Add below code to it

<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
    <module name="Custom_Outofstock" setup_version="2.0.0">

Now create file suggested in this answer given By Sohel Rana as below

Crate di.xml at app/code/Custom/Outofstock/etc/di.xml

add below code to it

<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
    <preference for="Magento\Catalog\Pricing\Render\FinalPriceBox" type="Custom\Outofstock\Pricing\Render\FinalPriceBox" />

Create Price render file FinalPriceBox.php at app/code/Custom/Outofstock/Pricing/Render/FinalPriceBox.php

Add below code to it

namespace Custom\Outofstock\Pricing\Render;

use Magento\Msrp\Pricing\Price\MsrpPrice;
use Magento\Framework\Pricing\Render\PriceBox as BasePriceBox;

class FinalPriceBox extends \Magento\Catalog\Pricing\Render\FinalPriceBox
    protected function _toHtml()
        $result = parent::_toHtml();

        if(!$result) {
            $result = BasePriceBox::_toHtml();
            try {
                /** @var MsrpPrice $msrpPriceType */
                $msrpPriceType = $this->getSaleableItem()->getPriceInfo()->getPrice('msrp_price');
            } catch (\InvalidArgumentException $e) {
                return $this->wrapResult($result);

            //Renders MSRP in case it is enabled
            $product = $this->getSaleableItem();
            if ($msrpPriceType->canApplyMsrp($product) && $msrpPriceType->isMinimalPriceLessMsrp($product)) {
                /** @var BasePriceBox $msrpBlock */
                $msrpBlock = $this->rendererPool->createPriceRender(
                        'real_price_html' => $result,
                        'zone' => $this->getZone(),
                $result = $msrpBlock->toHtml();

            return $this->wrapResult($result);

        return $result;

Your Answer

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

Browse other questions tagged or ask your own question.