Magento2: Address Book - "Add New Address" button

Created on 4 Oct 2016  路  5Comments  路  Source: magento/magento2

In the customer account Address Book the button to "Add New Address" in the Additional Address Entries section does nothing.

Preconditions

  1. Magento 2.1.1
  2. php 5.6.1

    Steps to reproduce

  3. Go to "Account" page

  4. Navigate to "Address Book"
  5. Click "Add New Address" button

    Expected result

  6. On "Add New Address" button click should prompt a new form to create an additional address

    Actual result

  7. On "Add New Address" button click nothing happens

Most helpful comment

@ytorbyk ahhh! I found the reason. In the javascript at the bottom of that page it is looking for the presence of an element with the class of "page-main". This class does not exist on my page so I changed it to look for "customer-address-index" the class on the body element and both links started working properly. Thank you for pointing me in the right direction!

All 5 comments

I have temporarily fixed this by adding a link tag around the "Add New Address" button inside of Magento_Customer/templates/address/book.phtml file. This is definitely not ideal in terms of how the rest of the Account actions are created/function.

However, upon fixing this bug I have discovered that the "Delete Address" button that shows after you have successfully added an additional address to your address book has an href="#" and therefore doesn't do anything...

I have created a new issue for this bug with the "Delete Address" button not working here: https://github.com/magento/magento2/issues/6877

Hi @btjackson11
It's interesting. I've checked the issue locally and the button works fine.
Are you sure you don't have any JavaScript errors on the page?
Try to clean browser cache.

The button links are added by JavaScript ('Add New Address' and 'Delete Address'): https://github.com/magento/magento2/blob/2.1/app/code/Magento/Customer/view/frontend/templates/address/book.phtml#L106-L109

@ytorbyk ahhh! I found the reason. In the javascript at the bottom of that page it is looking for the presence of an element with the class of "page-main". This class does not exist on my page so I changed it to look for "customer-address-index" the class on the body element and both links started working properly. Thank you for pointing me in the right direction!

Hi !

I have the same problem but I can't solve it.
Can you explain what you did exactly please ?

Thank you in advance !!

@marionvdw he just targeting the class, In default, it has a page-main class in your body tag. when you customize your theme some time it's missing that page-main class, that time js does not target your class so the file not calling

/Maegnto_customer/address.js

so you need to assign some existing class there. so he mentioned as customer-address-index

Was this page helpful?
0 / 5 - 0 ratings