0

enter image description here

I want to add a button with email address. I can add buttons on places like this. Can any body help me to figure out how to do this on the specific point. Any help should be highly appreciated.

1 Answer 1

0

Create a custom module, with an admin controller to post the order_id and new email address and saved logic. You could use a modal box to enter the new email address

You can either do 1 or 2 options

Option 1 (not recommended)

Rewrite template app/code/Magento/Sales/view/adminhtml/templates/order/view/info.phtml

See /app/code/Magento/Sales/view/adminhtml/layout/sales_order_view.xml

eg

MagePal/EditOrderEmail/view/adminhtml/layout/sales_order_view.xml

<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
  <body>
    <referenceBlock name="order_info" template="MagePal_EditOrderEmail::order/view/info.phtml" />

Then update the template and add the button at the appropriate location

Option 2

Use JavaScript to dynamically insert the button

MagePal/EditOrderEmail/view/adminhtml/layout/sales_order_view.xml

<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
<body>
    <referenceContainer name="content">
        <block class="MagePal\EditOrderEmail\Block\Adminhtml\Email\Edit" name="magepal_email_edit"
               template="MagePal_EditOrderEmail::email.phtml"/>
    </referenceContainer>
</body>

pseudo code (please use requireJs to load dependecy)

email.phtml

//add button 
jQuery('table.order-account-information-table tr a[href^="mailto:"]').parent().append( '<button>edit</button>' )

 //create modal logic (add form with email, order_id textfield) 
3
  • Thanks @Renon Stewart for reply, I have applied both options: With option 1, Order and Acount Information section goes away and with option 2 no output seems. Can you test this code snippet first ?
    – Ajwad Syed
    Commented Nov 28, 2018 at 6:35
  • I have built this functionality for M1 so I know the above logic will work. You will need to do some simple debug to see where your issue is. If you enter the about JS in Google Chrome console then the button should appear. Did you check to see if your code is been included? Commented Nov 28, 2018 at 15:47
  • @Ajwad Taqvi ... Take a look @ github.com/magepal/magento2-edit-order-email ... Unfinished, but 80% of the logic is there... please submit a PR if you finish the remaining code. Thanks Commented Nov 28, 2018 at 19:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.