0

I am planning to change product price from Category view and product page to “coming soon” I have a new product attribute which I have created and I can see that when I edit product page from admin area. If I enable that attribute the price is meant to change from the amount to “coming soon”

This is my Di.xml file

    <?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
    <!-- Product page -->
    <type name="Magento\Catalog\Model\Product">
        <plugin name="change_product" type="[vendor]\[module]\Plugin\Model\Product"/>
    </type>

    <!-- Price changed in category level -->
    <type name="Magento\Catalog\Block\Product\ListProduct">
        <plugin name="cataloghideprice_finalpricebox" type="[vendor]\[module]\Block\Product\ListProduct" />
    </type>

</config>

The category level works perfectly I can see coming soon, but the issue I am having is product page isn’t changing

Please can someone direct me to the right path.

1
  1. You need to create catalog_product_prices.xml into your extension on following path : vendor\Extension\view\base\layout\catalog_product_prices.xml

  2. Now copy the orginal file content catalog_product_prices.xml from following location : vendor\magento\module-catalog\view\base\layout\catalog_product_prices.xml

  3. Now replace following line

    <item name="default_amount_render_template" xsi:type="string">Magento_Catalog::product/price/amount/default.phtml</item>
    

    with this :

    <item name="default_amount_render_template" xsi:type="string">Vendor_Extension::product/price/amount/default.phtml</item>
    
  4. Now copy the template file from

    Magento_Catalog::product/price/amount/default.phtml
    

    to

    Vendor_Extension::product/price/amount/default.phtml
    
  5. Now apply your logic into this file :

    Vendor_Extension::product/price/amount/default.phtml 
    
16
  • How is this overriding the category or product page. Product/price/amount/default.phtml would this change the price for both area Jul 25 '20 at 5:50
  • you need to create that file into given templates folder and it will use to show on the product page. Jul 25 '20 at 6:13
  • I am kinda confused, I haven’t tried it I thought I will double check. This current default.phtml would this change on both areas as in product page and category level or would I need to change somewhere else as well Jul 26 '20 at 12:07
  • You can re-write this and then check. Jul 27 '20 at 5:11
  • Hi @DhirenVasoya sure I will give this a go today and let you know but thank you as well for the help. 😊 Jul 27 '20 at 6:39

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.