0

Can anyone provide a link or write out step-by-step instruction for adding a link to the Magento 2 shopping cart page? I have tried following several provided by 3rd parties, but I haven't had any luck.

1 Answer 1

0

Actually it's depends on where you need to add. So for now, let's assume you want to add this link in content container.

You have to add code in app/design//<theme_dir>/Magento_Checkout/layout/checkout_cart_index.xml

Code :

<referenceContainer name="content">
    <block name="block_name" class="Magento\Framework\View\Element\Html\Link">
        <arguments>
            <argument name="label" xsi:type="string" translate="true">Contact Us</argument>
            <argument name="href" xsi:type="string">testlink</argument>
            <argument name="name" xsi:type="string">testlink</argument>         
        </arguments>
    </block>
</referenceContainer>

If this help you to build your logic then hit like :)

Enjoy your coding !!! :)

Thank you
Hiren Patel

3
  • If I have a specific block already created ond working on other pages, can I use that? Oct 9, 2020 at 13:48
  • Yes, you can use it. <referenceContainer name="content"> <block name="block_name" class="<block_class>" template="Module_Name::test.phtml"> </block> </referenceContainer> Oct 9, 2020 at 16:21
  • I have followed your suggestion, Hiren, and it is working. Thanks for pointing me in the right direction. Oct 12, 2020 at 14:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.