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 
    
| improve this answer | |
  • How is this overriding the category or product page. Product/price/amount/default.phtml would this change the price for both area – Jack Brooks Jul 25 at 5:50
  • you need to create that file into given templates folder and it will use to show on the product page. – Dhiren Vasoya Jul 25 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 – Jack Brooks Jul 26 at 12:07
  • You can re-write this and then check. – Dhiren Vasoya Jul 27 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. 😊 – Jack Brooks Jul 27 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.