Add Custom Field to ContactUs Form

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
6 years ago
Hey,

I've been digging through a lot of thread in this forum to find a way to add a new form field to the ContactUs Form.
I added the attribute ("Phone", cause I want the customer to add a phone number) to the ContactUsModel as suggested by RomanovM here: https://www.nopcommerce.com/boards/t/41912/add-subject-field-in-the-contact-us-form-in-nopcommerce.aspx#167722

So i then updated my ContactUs.cshtml to include a form field for the phone-number. When I submit the form, the usual ContactUs Email is send, which only contains the following:


From: Name_I_typed_in - email@I_typed.in

Enquiry I typed in


Under CMS-System => Templates => Service.ContactUs is the template used for this email, which only consists of the token
%ContactUs.Body%
. I didn't find any way to style/code this email or add the phone-number to the %ContactUs.Body%-Token.

Is there any documentation that I'm missing or can someone point me in the right direction here?

Regards,

Chris
6 years ago
You missed an important part of what RomanovM said:

add your new fields in the ContactUsModel

Before you can reference the new fields on the view, they must be added to the model, and your solution recompiled.
If you do not use the SOURCE CODE version, this is not possible for you.
6 years ago
embryo wrote:
You missed an important part of what RomanovM said:

add your new fields in the ContactUsModel

Before you can reference the new fields on the view, they must be added to the model, and your solution recompiled.
If you do not use the SOURCE CODE version, this is not possible for you.


Hi,
thanks for your answer.

I already did this. I downloaded the source code, opened the projekt via VisualStudio 2015.
Where I searched for the ContactUsModel (Presentation => Nop.Web => Models => Common => ContactUsModel.cs) and added the attribute phone like this:

   [AllowHtml]
   [NopResourceDisplayName("ContactUs.Phone")]
   public string Phone { get; set; }


Then I published the Nop.Web and merged the new files with my existing NopCommerce.
Now I edited the view of the ContactUs Page to include a FormField for Phone. I can send the Email, but the phone number won't be displayed in the email received.
6 years ago
/Push

Still struggling with this.
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.