The contact us code in commonController.cs is like:
//contact us page [NopHttpsRequirement(SslRequirement.No)] public ActionResult ContactUs() { var model = new ContactUsModel() { Email = _workContext.CurrentCustomer.Email, Phone = _workContext.CurrentCustomer.Phone, // I added FullName = _workContext.CurrentCustomer.GetFullName(), DisplayCaptcha = _captchaSettings.Enabled && _captchaSettings.ShowOnContactUsPage }; return View(model); } [HttpPost, ActionName("ContactUs")] [CaptchaValidator] public ActionResult ContactUsSend(ContactUsModel model, bool captchaValid) { //validate CAPTCHA if (_captchaSettings.Enabled && _captchaSettings.ShowOnContactUsPage && !captchaValid) { ModelState.AddModelError("", _localizationService.GetResource("Common.WrongCaptcha")); }
if (ModelState.IsValid) { string email = model.Email.Trim(); string phone = model.Phone.Trim(); //added by me string fullName = model.FullName; string subject = string.Format(_localizationService.GetResource("ContactUs.EmailSubject"), _storeContext.CurrentStore.Name);
var emailAccount = _emailAccountService.GetEmailAccountById(_emailAccountSettings.DefaultEmailAccountId); if (emailAccount == null) emailAccount = _emailAccountService.GetAllEmailAccounts().FirstOrDefault(); if (emailAccount == null) throw new Exception("No email account could be loaded");
string from = null; string fromName = null; string body = Core.Html.HtmlHelper.FormatText(model.Enquiry, false, true, false, false, false, false); //required for some SMTP servers if (_commonSettings.UseSystemEmailForContactUsForm) { from = emailAccount.Email; fromName = emailAccount.DisplayName; body = string.Format("<strong>From</strong>: {0} - {1}<br /><br />{2}", Server.HtmlEncode(fullName), Server.HtmlEncode(email), body); } else { from = email; fromName = fullName; } _queuedEmailService.InsertQueuedEmail(new QueuedEmail() { From = from, FromName = fromName, To = emailAccount.Email, ToName = emailAccount.DisplayName, Priority = 5, Subject = subject, Body = body, CreatedOnUtc = DateTime.UtcNow, EmailAccountId = emailAccount.Id });
FYI, The phone input is added to the contact us form.
There is an error which is the NOP.web.framework.dll can't be found under nop.framework/bin/debug/. After the file was moved to the folder, the phone input can be seen in the contact us page.
Well, what is the solution I'm still not able to figure out. My situation is absolutely same & and I did all the above suggestions. But the problem remains. So, have anyone got any solution to add phone field in contactus page for NopCommerce 3.80, I would appreciate the help.