1

I have added in Magento_Contact module custom field with order number:

                <div class="field telephone">
                    <div class="control">
                        <input placeholder="<?php echo __('Your Phone') ?>" name="telephone" id="telephone"
                               title="<?php /* @escapeNotVerified */
                               echo __('Phone Number') ?>" value="" class="input-text" type="text"/>
                    </div>
                </div>
                                    <div class="field ordernumber">
                    <div class="control">
                        <input placeholder="<?php echo __('Order Number') ?>" name="ordernumber" id="ordernumber"
                               title="<?php /* @escapeNotVerified */
                               echo __('Order Number') ?>" value="" class="input-text" type="text"/>
                    </div>
                </div>

screen: https://prnt.sc/s5fgtu

But when I sent a message via this form after filling this custom field (order number), when I receive a message from this contact module then this field is not displayed.

screen: https://prnt.sc/s5fh54

Any solution how to do?

2
  • custom filed not received in email ??? Commented Apr 24, 2020 at 19:51
  • Just after filling this custom field (order number), when I receive a message from this contact module, I can't see this field. You can check screen.
    – Sylvester
    Commented Apr 24, 2020 at 19:58

1 Answer 1

2

This code is correct :-

<div class="field ordernumber">
                    <div class="control">
                        <input placeholder="<?php echo __('Order Number') ?>" name="ordernumber" id="ordernumber"
                               title="<?php /* @escapeNotVerified */
                               echo __('Order Number') ?>" value="" class="input-text" type="text"/>
                    </div>
                </div> 

Now, go to MARKETING > Communication > Email Templates in the Magento Admin section. Click "Add New Template" and from the "Template" dropdown box select "Contact Form" then "Load Template". Under template content you will see:

{{trans "Name: %name" name=$data.name}}
{{trans "Email: %email" email=$data.email}}
{{trans "Phone Number: %telephone" telephone=$data.telephone}}
{{trans "Comment: %comment" comment=$data.comment}}

Add your new field and this code :-

{{template config_path="design/email/header_template"}}

<table class="message-details">
    <tr>
        <td><strong>{{trans "Name"}}</strong></td>
        <td>{{var data.name}}</td>
    </tr>
    <tr>
        <td><strong>{{trans "Email"}}</strong></td>
        <td>{{var data.email}}</td>
    </tr>
    <tr>
        <td><strong>{{trans "Phone"}}</strong></td>
        <td>{{var data.telephone}}</td>
    </tr>
<tr>
           <td><strong>{{trans "ordernumber"}}</strong></td>
        <td>{{var data.ordernumber}}</td>
    </tr>
</table>
<p><strong>{{trans "Message"}}</strong></p>
<p>{{var data.comment}}</p>

{{template config_path="design/email/footer_template"}}

And save template. Now you need to tell Magento to use this new template for the Contact form. Go to STORES > Settings > Configuration > General > Contacts and select "Contacts". Under "Email Options", select your new template under the "Email Options" > "Email Template" dropdown box. Click on Save Button.

Hope help you

Thanks ...

1
  • Thanks. Working perfect :-)
    – Sylvester
    Commented Apr 24, 2020 at 20:06

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.