1

I want to remove some links in the customer account side navigation section on my Magento ver. 2.1.8 store.

So, I have created a path in my custom theme:

app/design/frontend/[Namespace]/[Theme]/Magento_Customer/layout/customer_account.xml

My customer_account.xml file:

<?xml version="1.0"?>
<!--
/**
 * Copyright © 2016 Magento. All rights reserved.
 * See COPYING.txt for license details.
 */
-->
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
    <body>
        <!-- Removing the link -->
        <referenceBlock name="block-name" remove="true"/>    
    </body>
</page>

I found few threads and tutorials online such as: How to add/remove links on my account navigation magento2?

However, I don't think all the links are included in those tutorials. How can I find out what is the name of this referenceBlock so I can remove it?

This i my customer account navigation section: enter image description here

I need to remove:

  • My Downloadable products
  • Stored payment methods
  • Billing agreements
  • My Saved cards
  • My Recurring profiles

I am sure the downloadable products, billing agreement and my saved cards can be deleted using:

<referenceBlock name="customer-account-navigation-downloadable-products-link" remove="true"/>
<referenceBlock name="customer-account-navigation-billing-agreements-link" remove="true"/>
<referenceBlock name="customer-account-navigation-my-credit-cards-link" remove="true"/>

But how do I delete the Stored Payment Methods and My Recurring profiles links?

2 Answers 2

2

Put below code in this file

app/design/frontend/[Namespace]/[Theme]/Magento_Customer/layout/customer_account.xml

<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
    <body>
        <referenceBlock name="customer_account_navigation">
            <referenceBlock name="customer-account-navigation-my-credit-cards-link" remove="true"/>
        </referenceBlock>
    </body>
</page>

run php bin/magento cache:clean command

run php bin/magento cache:flush command

Here is the reference link for all the blocks - https://gist.github.com/matt-bailey/3a5b36186a599b8653bb3b05115ecd90

5
  • The question asks how to delete the Stored Payment Methods and My Recurring profiles links, do you know how can I find the reference for it?
    – Greg
    Jan 25, 2018 at 11:19
  • Referance name customer-account-navigation-my-credit-cards-link is responsible for those two links?
    – Greg
    Jan 25, 2018 at 11:23
  • Yes correct - customer-account-navigation-my-credit-cards-link is responsible for Stored Payment Methods and above code will removed that Jan 25, 2018 at 11:23
  • It wasn't me down-voting. What is responsible for My Saved cards and for My Recurring profiles links?
    – Greg
    Jan 25, 2018 at 11:25
  • @BareFeet - Here is the reference link for all the blocks - gist.github.com/matt-bailey/3a5b36186a599b8653bb3b05115ecd90 Jan 25, 2018 at 11:29
0

I think if you add this code to the custom_account.xml file located at:

app/design/frontend/**YourWebsite**/**NameOfYourTheme**/Magento_Customer/layout/customer_account.xml

<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">

    <body>
        <referenceBlock name="customer_account_navigation">
            <referenceBlock name="customer-account-navigation-my-credit-cards-link" remove="true"/>
        </referenceBlock>
    </body>

</page>

I think this will remove the links as you have requested.

Hope this helps!

EDIT: You should also clean your cache and redeploy your static-content. This should make the changes appear. If not, try deleting your browser cache. Caching issues are normally the problem.

Your Answer

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

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