Template and layout overrides (Luma)
What it does
Change the markup of EasyQuote's storefront pages in a Luma-based theme without editing the module. Layout XML and templates follow Magento's normal theme fallback, with one exception: the request form popup is built in PHP, not from a layout handle.
Before you start
- A theme of your own that inherits from Magento Luma or Blank, under
app/design/frontend/<vendor>/<theme>. - Shell access to run
bin/magentoon the store. - For a Hyvä theme, use Hyvä templates and Tailwind instead.
Steps
Find the handle and the template
The storefront layouts of MageMe_EasyQuote are in view/frontend/layout/:
| Handle | Where it shows | Blocks you can reference |
|---|---|---|
default | Every page | minicart.mm.easyquote.request.button (cart/minicart_button.phtml) in header.container |
checkout_cart_index | Cart page | cart.mm.easyquote.request.button (cart/cart_button.phtml) in cart.summary; mm.easyquote.quote.cart.number and mm.easyquote.quote.cart.comment inside additional.product.info |
customer_account | Customer account | The My Quotes link in customer_account_navigation |
easyquote_quote_index | My Quotes list | quote.index (customer/account/quotes.phtml) |
easyquote_quote_view | Quote page | quote.status, quote.date, quote.actions.container with easyquote.quote.info.buttons inside it, easyquote.quote.view, quote_items, the item renderers easyquote.quote.items.renderers.*, the price and quantity renderers easyquote.quote.item.*, quote_totals |
easyquote_quote_decline | Decline page | quote.status, quote.date, easyquote.quote.info.buttons, easyquote.quote.view (customer/account/decline.phtml) |
easyquote_request_success | Page after a request | request.success (request/success.phtml) |
sales_order_view, sales_order_print, sales_email_order_items | Order page, printout and order email | The quote comments block (order/view/comments.phtml) |
easyquote_quote_email_items, easyquote_request_email_items | Quote and request emails | Item grids, see Email and PDF template variables |
- Pick the block from the table above.
- Open its template in
MageMe_EasyQuote/view/frontend/templates/. With Composer, the module is undervendor/mageme/module-easyquote/.
Override a template
- Copy the template into your theme under the same relative path. For example, copy
cart/cart_button.phtmltoapp/design/frontend/<vendor>/<theme>/MageMe_EasyQuote/templates/cart/cart_button.phtml. - Change the copy. Keep the element IDs and
data-attributes the module's JavaScript looks for. - Run
bin/magento cache:clean layout block_html full_page.
Change the layout
- Create
app/design/frontend/<vendor>/<theme>/MageMe_EasyQuote/layout/<handle>.xml, for examplecheckout_cart_index.xml. - Use
referenceBlockwith the block name from the table, for example to move or removecart.mm.easyquote.request.button. - Run
bin/magento cache:clean layout full_page.
Change the request form popup
The Get Quote button loads the form over AJAX from easyquote/request/formRenderer. That controller, MageMe\EasyQuote\Controller\Request\FormRenderer, creates the MageMe\EasyQuote\Block\Request\Form block in PHP and wraps it in a div with the class easyquote-popup. No layout handle is involved, so layout XML can't reach the form.
| To change | Do this |
|---|---|
| The form or one field | Override the template in your theme: request/form.phtml, request/form/field/<field>.phtml (email, password, firstname, lastname, company, phone_number, message, file_attachments), request/form/custom_field/<type>.phtml (text, dropdown, radio, checkbox, date), request/form/script.phtml, request/form/submit.phtml |
| The block class | Add an afterGetFormBlockType plugin on FormRenderer that returns your subclass of Block\Request\Form |
| The data passed to the block | Add an afterGetFormBlockData plugin on FormRenderer |
| The field order | Set Fields Order in the request form settings, no code needed |
- Copy the field template into
app/design/frontend/<vendor>/<theme>/MageMe_EasyQuote/templates/request/form/field/. - Change the copy.
- Run
bin/magento cache:clean block_html full_page.
The form CSS (css/request.css, plus phone, attachment and date picker CSS when those fields are on) is added to the page by the layout_load_before observer Observer\LayoutLoadBefore, not by layout XML.
What you should see
After the cache clean, the storefront page shows your markup. In developer mode, template hints (Stores → Configuration → Advanced → Developer → Debug) show the path from your theme for the block you changed.
Limits
- The request form popup has no layout handle. Change it through templates or plugins only.
- The Developer settings move and style the buttons without code: Button Selector Cart and Button Selector Mini Cart take a CSS selector the button is moved into, Custom Button CSS Classes and Custom Popup CSS Classes add classes. See Settings: Developer and Hyvä Theme Developer, the entries for Button Selector Mini Cart, Custom Button CSS Classes and Custom Popup CSS Classes.
- Since 1.7.4 the request form popup locks page scrolling with the class
mm-easyquote-scroll-lockon thehtmlelement, and no longer fixes thebodyin place. Theme CSS written for the oldbody.tingle-enabled { position: fixed }behavior needs a review. - The checkout scripts are extended through
requirejs-config.js: a mixin forMagento_Checkout/js/view/minicartand dependencies of the shipping and billing address views. A theme that replaces those components has to keep the EasyQuote scripts. - An EasyQuote update can change a template. Compare your copies with the new versions after each update.
Troubleshooting
- Your template copy has no effect. Check that the store view uses your theme, that the path repeats the module's path after
templates/, and clean theblock_htmlandfull_pagecaches. - The request form changes don't show. The popup is fetched without page cache, but the browser may keep the old response. Reload without cache and check the response of
easyquote/request/formRenderer. - The Get Quote button stopped opening the form. Your copy of
cart/cart_button.phtmlorcart/minicart_button.phtmllost an element ID the inline script uses. Compare it with the module's template.
What's next
- Hyvä templates and Tailwind: the same work for a Hyvä theme.
- Email and PDF template variables: change the emails and the quote PDF.