Add a Link in My Account’s Left Menu

 MyAccountMenu component is used to add a link to the page in the navigation bar. 

The component has two key methods: one to add to a group and one to add entries to groups.

To create a new entry in the menu :

  1. Create an object to represent how you want the entry to behave
  2. Use the MyAccountMenu component’s method to add it

Once the method has been called and the object verified, the menu will automatically update to include your new entry.

mountToApp: function mountToApp (container)
{
  var MyAccountMenu = container.getComponent('MyAccountMenu');

  var termsAndConditionsGroupEntry = {
    id: 'termsandconditions'
  , groupid: 'settings'
  , index: 99
  , url: 'update-terms-and-conditions'
  , name: _.translate('Terms and Conditions')
  }

  MyAccountMenu.addGroupEntry(termsAndConditionsGroupEntry);

  return new TermsAndConditionsMyAccountRouter(container)
}
  • id — id assigned to the newly entered link
  • groupid — this is the group you want to add it to, and you can quickly find the menu IDs by inspecting the group’s node and reading its data-id attribute value
  • index —number where its to be appear, indexes start at 0
  • url — url of newly created link
  • name — Name of the link to be added

save the code run it locally

Leave a comment

Your email address will not be published. Required fields are marked *