Managing My Account Navigation Links in Magento 2

0
76
Inchoo_Nav_Links

Step 1

First of all, you need a create customer_account.xml in your theme in:

app/design/frontend/_YOUR_VENDOR_/_YOUR_THEME_/Magento_Customer/layout/customer_account.xml

Add a Custom Link

All we need to do is add this code to our layout xml file:

<referenceBlock name="customer_account_navigation">
    <block class="Magento\Framework\View\Element\Html\Link\Current" name="customer-account-navigation-custom-link" after="-" >
         <arguments>
             <argument name="label" xsi:type="string" translate="true">Custom Link Label</argument>
             <argument name="path" xsi:type="string">custom-path</argument>
         </arguments>
    </block>
</referenceBlock>

Re-order links

<move element="LINK_YOU_WANT_TO_MOVE" destination="customer_account_navigation" AFTER_OR_BEFORE="NEW_POSITION" />
 
<!-- eg. "My Wish List" move after "My Orders" -->
<move element="customer-account-navigation-wish-list-link" destination="customer_account_navigation" after="customer-account-navigation-orders-link" />

We “moved” the element from its original location and placed it back there, at the same time telling M2 to place it after/before link we want.

Remove the link

To shorten and simplify the story, in the example below I will immediately show you how to delete all links from the navigation one by one.

<!-- Store credit -->
<referenceBlock name="customer-account-navigation-customer-balance-link" remove="true"/>
 
<!-- Downloadable product link -->
<referenceBlock name="customer-account-navigation-downloadable-products-link" remove="true"/>
 
<!-- Subscription link -->
<referenceBlock name="customer-account-navigation-newsletter-subscriptions-link" remove="true"/>
 
<!-- Billing agreement link -->
<referenceBlock name="customer-account-navigation-billing-agreements-link" remove="true"/>
 
<!-- Product review link -->
<referenceBlock name="customer-account-navigation-product-reviews-link" remove="true"/>
 
<!-- My credit card link -->
<referenceBlock name="customer-account-navigation-my-credit-cards-link" remove="true"/>
 
<!-- Account link -->
<referenceBlock name="customer-account-navigation-account-link" remove="true"/>
 
<!-- Account edit link -->
<referenceBlock name="customer-account-navigation-account-edit-link" remove="true"/>
 
<!-- Address link -->
<referenceBlock name="customer-account-navigation-address-link" remove="true"/>
 
<!-- Orders link -->
<referenceBlock name="customer-account-navigation-orders-link" remove="true"/>
 
<!-- Wish list link -->
<referenceBlock name="customer-account-navigation-wish-list-link" remove="true"/>
 
<!-- Gift card link -->
<referenceBlock name="customer-account-navigation-gift-card-link" remove="true"/>
 
<!-- Gift registry -->
<referenceBlock name="customer-account-navigation-giftregistry-link" remove="true"/>
 
<!-- Reward points -->
<referenceBlock name="customer-account-navigation-reward-link" remove="true"/>
 
<!-- Order by SKU -->
<referenceBlock name="customer-account-navigation-checkout-sku-link" remove="true"/>

Ref: inchoo