"Request a quote" form for nopCommerce project

9 years ago
In e-commerce business we deal with products and the services. Many times we deals with quotes also, so how about adding a page/form of "Request a quote" ?

Today, in most of the e-commerce stores we see "Request a quote" form that needs to be filled by online customer to get price and other details regarding product(s).

Having "Request a quote" form on your online store is an important feature in e-commerce business

Here's the code to add "Request a quote" page in your project...

Add an aspx page and name it as : Requestaquote.aspx


Requestaquote.aspx

<%@ Page Language="C#" MasterPageFile="~/MasterPages/TwoColumn.master" AutoEventWireup="true"
CodeBehind="Requestaquote.aspx.cs" Inherits="NopSolutions.NopCommerce.Web.Requestaquote" %>

<asp:Content ID="Content1" ContentPlaceHolderID="cph1" runat="server">
    
<asp:Label ID="ResultLabel" ForeColor="Red" runat="server" ></asp:Label><br />
    
Name: <asp:TextBox ID="NameTextBox" runat="server"></asp:TextBox><br />

Contact Number: <asp:TextBox ID="ContactNumberTextBox" runat="server"></asp:TextBox><br />
    
E-mail Address: <asp:TextBox ID="EmailTextBox" runat="server"></asp:TextBox><br />

Company: <asp:TextBox ID="CompanyTextBox" runat="server"></asp:TextBox><br />
    
Company Address: <asp:TextBox ID="AddressTextBox" runat="server"></asp:TextBox><br />
    
Enquiry (Message Body):
<br />
    <asp:TextBox ID="EnquiryTextBox" TextMode="multiline" runat="server"
        Height="155px" Width="430px"></asp:TextBox><br /><br />
    
<asp:Button ID="SubmitButton" runat="server" Text="Submit"
        onclick="SubmitButton_Click" />

</asp:Content>




Requestaquote.aspx.cs


using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Net.Mail;
using NopSolutions.NopCommerce.BusinessLogic.Messages;

namespace NopSolutions.NopCommerce.Web
{
    public partial class Requestaquote : BaseNopPage
    {
        protected void Page_Load(object sender, EventArgs e)
        {
        }

        protected void SubmitButton_Click(object sender, EventArgs e)
        {
            string mailContent = string.Format("Name: {0}, Contact_Number:{1}, E-mail_Address:{2}, Company_Name:{3}, Company_Address:{4},  Enquiry:{5}",  NameTextBox.Text, ContactNumberTextBox.Text, EmailTextBox.Text, CompanyTextBox.Text, AddressTextBox.Text, EnquiryTextBox.Text);
            try
            {
                MailAddress from = new MailAddress(MessageManager.AdminEmailAddress, MessageManager.AdminEmailDisplayName);
                MailAddress to = new MailAddress("[email protected]");
                MessageManager.SendEmail("Request Quote", mailContent, from, to);
                ResultLabel.Text = "We have received your quote... Thank You !!!";
            }
            catch (Exception ex)
            {
                ResultLabel.Text = "Error: " + ex.Message;
            }
        }
    }
}




In Requestaquote.aspx.cs file please replace this "[email protected]" with your e-mail address where you want to receive your quotes from your customers...

This code is doing the basic functionality of a "Request Quote" form, you can add / remove any fields from the code and design the form according to your requirements.


Once you are done with the code, save it and add it in your main menu or wherever you want the link "Request Quote" to be displayed...
9 years ago
good job!
9 years ago
How can we do this in 1.80? Will the same work in the new version?

Daniel
9 years ago
ABC --- great job...

After creating the aspx pages...

How can I get one to reside in the same left column "Categories' list in the basic nopcommerce 1.80 version?

FLETCH
9 years ago
SAIBR.com wrote:
How can we do this in 1.80? Will the same work in the new version?

Daniel


Hello Daniel, i tested the above code in 1.4 version so i am not sure about 1.8 version

For you I just created code for 1.8version, here it is: (you can try both if you want)

Use the same code for Requestaquote.aspx

Now here's the code for Requestaquote.aspx.cs

using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Net.Mail;
using NopSolutions.NopCommerce.BusinessLogic.Messages;

namespace NopSolutions.NopCommerce.Web
{
    public partial class Requestaquote : BaseNopPage
    {
      

        protected void Page_Load(object sender, EventArgs e)
        {
            
        }



        protected void SendEmail_Click(object sender, EventArgs e)
        {
          

            try
            {
                MailAddress from = new MailAddress(MessageManager.AdminEmailAddress, MessageManager.AdminEmailDisplayName);
                MailAddress to = new MailAddress(MessageManager.AdminEmailAddress, MessageManager.AdminEmailDisplayName);

              
                MailMessage mm = new MailMessage(from, to);

                
                mm.Subject = "Quote Request From Your Website";
                mm.Body = "<b>" + "Sender's Name: " + "</b>" + NameTextBox.Text + "<b>" + "Sender's Number: " + "</b>" + ContactNumberTextBox.Text + "<b>" + "Sender's Company Name: " + "</b>" + CompanyTextBox.Text + "<b>" + "Sender's E-mail Address: " + "</b>" + EmailTextBox.Text + "<br/>" + "<br/>" + "<b>" + "Company Address: " + "</b>" + AddressTextBox.Text + "<br/>" + "<br/>" + "<b>" + "Enquiry (Message Body): " + "</b>" + "<br/>" + EnquiryTextBox.Text.Replace("\n", "<br />");
                mm.IsBodyHtml = true;

                
                MessageManager.SendEmail(mm);

      
                ResultLabel.Visible = true;
                ResultLabel.ForeColor = System.Drawing.Color.Green;
                ResultLabel.Text = "We have received your information...Thank You !!!";
            }
            catch (SystemException err)
            {
                ResultLabel.Visible = true;
                ResultLabel.ForeColor = System.Drawing.Color.Red;
                ResultLabel.Text = err.Message;
            }


          
        }

    }
}




I haven't tested this code, it is handwritten by me, but still it should work, if it is not working then let me know, i'll fix it..
9 years ago
creativeventures wrote:
ABC --- great job...

After creating the aspx pages...

How can I get one to reside in the same left column "Categories' list in the basic nopcommerce 1.80 version?

FLETCH


Hello FLETCH

you can try adding request quote page in category section like this:

First add a Recource string value for request a quote in admin section > Content Manager > Localization

Now

Go to Modules / CategoryNavigation.ascx (add the bold code)

<%@ Control Language="C#" AutoEventWireup="true"
    Inherits="NopSolutions.NopCommerce.Web.Modules.CategoryNavigation" Codebehind="CategoryNavigation.ascx.cs" %>
<div class="block block-category-navigation">
    <div class="title">
        <%=GetLocaleResourceString("Category.Categories")%>
    </div>
    <div class="clear"></div>
    <div class="listbox">
        <ul>
            <asp:PlaceHolder runat="server" ID="phCategories" EnableViewState="false" />
<div class="clear"></div>
<li><a href="<%=Page.ResolveUrl("~/requestaquote.aspx")%>">
                <%=GetLocaleResourceString("Requestaquote.RequestQuote")%></a> </li>

        </ul>
    </div>
</div>


(if above code doesn't work then try removing "<div class="clear"></div>" before requestaquote code)


In you want to add request a code in Information block, then

Go to Modules / InfoBlock.ascx

add the bold code like this:

<div class="listbox">
        <ul>
<li><a href="<%=Page.ResolveUrl("~/requestaquote.aspx")%>">
                <%=GetLocaleResourceString("Requestaquote.RequestQuote")%></a> </li>


            <li><a href="<%=Page.ResolveUrl("~/contactus.aspx")%>">
                <%=GetLocaleResourceString("ContactUs.ContactUs")%></a> </li>
            <li><a href="<%=Page.ResolveUrl("~/aboutus.aspx")%>">
                <%=GetLocaleResourceString("Content.AboutUs")%></a></li>
            <% if (BlogManager.BlogEnabled)
               { %>
            <li><a href="<%= SEOHelper.GetBlogUrl()%>">
                <%=GetLocaleResourceString("Blog.Blog")%></a></li>
            <%} %>
            <% if (ForumManager.ForumsEnabled)
               { %>
            <li><a href="<%= SEOHelper.GetForumMainUrl()%> ">
                <%=GetLocaleResourceString("Forum.Forums")%></a></li>
            <%} %>
            <% if (ProductManager.RecentlyAddedProductsEnabled)
               { %>
            <li><a href="<%=Page.ResolveUrl("~/recentlyaddedproducts.aspx")%>">
                <%=GetLocaleResourceString("Products.NewProducts")%></a></li>
            <%} %>
            <% if (ProductManager.RecentlyViewedProductsEnabled)
               { %>
            <li><a href="<%=Page.ResolveUrl("~/recentlyviewedproducts.aspx")%>">
                <%=GetLocaleResourceString("Products.RecentlyViewedProducts")%></a></li>
            <%} %>
            <% if (ProductManager.CompareProductsEnabled)
               { %>
            <li><a href="<%=Page.ResolveUrl("~/compareproducts.aspx")%>">
                <%=GetLocaleResourceString("Products.CompareProductsList")%></a></li>
            <%} %>
            <li><a href="<%=Page.ResolveUrl("~/sitemap.aspx")%>">
                <%=GetLocaleResourceString("Content.Sitemap")%></a></li>
            <li><a href="<%=Page.ResolveUrl("~/shippinginfo.aspx")%>">
                <%=GetLocaleResourceString("Content.Shipping&Returns")%></a></li>
            <li><a href="<%=Page.ResolveUrl("~/privacyinfo.aspx")%>">
                <%=GetLocaleResourceString("Content.PrivacyNotice")%></a></li>
            <li><a href="<%=Page.ResolveUrl("~/conditionsinfo.aspx")%>">
                <%=GetLocaleResourceString("Content.ConditionsOfUse")%></a></li>
        </ul>
    </div>

9 years ago
Thanks "MIKE"...I'll try that ASAP

Appreciate your help !
FLETCH
9 years ago
Sweet!! I will test it shortly!

Thanks!

Daniel
9 years ago
abc:

http://staging.saibr.com/requestdemoaccess.aspx

throws an error, looks like from the TwoColumn.master...

Did I screw something up?

Daniel
9 years ago
Mike,
Have you been able to get the quote request to work with 1.8 yet? If so, could you please post the code for me?