0

I have modified the final_price.phtml to customize the final price on the product page. It is working fine. But I am getting the same customization on Category page which I do not want. Please let me know how can I use different final price templates for Product and Category pages.

1

Please follow below steps

Step 1 for configurable product Create template file final_price.phtml file, in my case the file path is app/design/frontend/{{companyname}}/{{themename}}/Magento_ConfigurableProduct/templates/product/price/final_price.phtml

<?php
$objectManager = \Magento\Framework\App\ObjectManager::getInstance();
$requestInterface = $objectManager->get('Magento\Framework\App\RequestInterface');
$showaction = $requestInterface->getFullActionName();
?>
<?php if ($showaction == "catalog_product_view"): ?>
  /* your code */
<?php endif; ?>
<?php if ($showaction == "catalog_category_view"): ?>
  /* your code */
<?php endif; ?>

Step 2 for simple product create template file final_price.phtml at path app/design/frontend/{{companyname}}/{{themename}}/Magento_Catalog/templates/product/price/final_price.phtml

<?php
$objectManager = \Magento\Framework\App\ObjectManager::getInstance();
$requestInterface = $objectManager->get('Magento\Framework\App\RequestInterface');
$showaction = $requestInterface->getFullActionName();
?>
<?php if ($showaction == "catalog_product_view"): ?>
  /* your code */
<?php endif; ?>
<?php if ($showaction == "catalog_category_view"): ?>
  /* your code */
<?php endif; ?>
  • Great answer. It worked for me. A little big fix "==" is needed. – Ahmad Baig Jan 31 '19 at 8:47
  • @AhmadBaig now check it. fixed issue. – HIren Kadivar Jan 31 '19 at 8:59
  • @AhmadBaig if it is working please accept my answer. Thanks – HIren Kadivar Jan 31 '19 at 9:06
0

Magento uses same final_price.phtml file all over the website to show prices. You can add your controller check on price to work around on product detail page.

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.