Question

I extended Magento_Catalog in a custom theme and added the following block:

<?xml version="1.0"?>
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
    <body>
        <referenceContainer name="product.info.main">
            <block class="Magento\Framework\View\Element\Template" name="lvluplink" after="product.info.price" template="Magento_Catalog::customline.phtml" />
        </referenceContainer>
    </body>
</page>

the template:

<a class="primary action" href="https://google.com"><?= __('Custom Button') ?></a>

The link shows up in the store, but clicking the link does nothing. I am running Magento 2.3.4 in developer mode and have run:

bin/magento setup:upgrade
bin/magento setup:di:compile
bin/magento setup:static-content:deploy -f
bin/magento cache:clean
bin/magento cache:flush
Was it helpful?

Solution 2

I had developer hints on. This prevents any links or buttons from being clicked on the page. Turned off the hints and the link works as expected.

OTHER TIPS

Try this code

1.app/design/frontend/Mage/Mohit/Magento_Catalog/templates/product/customline.phtml

<a class="primary action" href="https://google.com"><?= __('Custom Button') ?></a>

2.app/design/frontend/Mage/Mohit/Magento_Catalog/layout/catalog_product_view.xml

<?xml version="1.0"?>
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
    <body>
        <referenceContainer name="product.info.main">
            <block class="Magento\Framework\View\Element\Template" name="lvluplink" after="product.info.price" template="Magento_Catalog::product/customline.phtml" />
        </referenceContainer>
    </body>
</page>

And after run the php bin/magento c:f

Output :-

enter image description here

And click button working fine.

Hope this help you

Thanks ...

Licensed under: CC-BY-SA with attribution
Not affiliated with magento.stackexchange
scroll top