How to override address/book phtml in Magento 2?

You can override the book.phtml file in Magento 2 using XML.
Book template used to display the address book of the customer with default billing and shipping address at the top of the Address book page.

Book Block class contains the native method for the template.
You can override using theme or module level,

  • 1. Theme Level,
  • 2. Module Level,

When you explore the customer_address_index.xml file from the customer module, You can see the address_book block that will be used to display the address book page on the frontend.

In your module create the same XML file, app/code/Jesadiya/Book/view/frontend/layout/customer_address_index.xml,

Create Template file to override book.phtml,
app/code/Jesadiya/Book/view/frontend/templates/address/book.phtml

In the above module, Jesadiya_Book is the Module name for simplicity.

Keep the required content from the Core template and modify your changes. If you want to change an additional section in a page, Override address/grid.phtml in Magento 2.

Clear Cache to see changes,
php bin/magento cache:flush

This is the simplest way to override the address book content in Magento 2.

One Reply to “How to override address/book phtml in Magento 2?”

Leave a Reply