The 5th annual nopCommerce conference will take place in India on the 10th-11th of October. Please find more about this event here

Request Quote Form (for 1.80 and 1.90)

1 2 3 4 >
Posted: November 18, 2010 at 1:57 AM Quote #30211
This modification adds a quote request form to a site. It is an update of the following topic, but uses no code from it, it only uses the field names for the quote request form:
https://www.nopcommerce.com/boards/t/5909/request-a-quote-form-for-nopcommerce-project.aspx

The modification is more related to the Contact Us form that is included with nopCommerce -it uses a topic for providing additional information, field names are localized, it inserts the message into the message queue, and is styled like the rest of the site. Note that all fields are required to submit the quote (remove ValidationGroup="RequestQuote" from the control to make a field optional).

Download Files:
http://www.mediafire.com/file/pxbwv1rfwtczu5a/RequestQuote_UPDATED.zip (for 1.80)
http://www.mediafire.com/file/arpa7b710a2gl4c/RequestQuote_190_updated.zip (for 1.90) (UPDATED)

Screenshots:
Request Quote Form (1.80)
Request Quote Form (1.90)
Sample Email Message Format


To install, follow the instructions in the README.txt file in the download.

.
This post/answer is useful
2
This post/answer is not useful

Please login or register
to vote for this post.

(click on this box to dismiss)
Posted: November 18, 2010 at 6:45 AM Quote #30221
Thank you so so so so so very much mb for your help.

can't wait to try your code on my website.

I would like to have 2 request forms on the website, one will send information to store owner and other will sent information to 2 or 3 e-mail addresses (not the store owner)

What should i do in the code if i want to send filled information from the above form to a list of e-mail addresses instead of store owner ?

E-mail addresses like : [email protected], [email protected], [email protected]
This post/answer is useful
0
This post/answer is not useful

Please login or register
to vote for this post.

(click on this box to dismiss)
nopCommerce - Amazing Project
Thank You nopcommerce team !
Posted: November 18, 2010 at 2:50 PM Quote #30264
The code download in the original post in this topic has been updated to use the CC and BCC email fields (specified in settings) so you can send the quote request to additional recipients. Both these settings are optional, but if you use them, you will need to separate the email addresses for the Value with a semicolon (;). Additionally, a RequiredFieldValidator has been added for the Additional Information (enquiry) field.

Add the new settings in Administration > Configuration > All Settings > Add new: (settings are in SQL script in download also)
(replace example email addresses or leave value blank)
Name : RequestQuote.CCEmails
Value: [email protected]; [email protected]; [email protected]
    OR    
Name : RequestQuote.BCCEmails
Value: [email protected]; [email protected]; [email protected]

.
This post/answer is useful
0
This post/answer is not useful

Please login or register
to vote for this post.

(click on this box to dismiss)
Posted: November 18, 2010 at 3:58 PM Quote #30275
thank you mb for getting back on this topic. I truly appreciate it!

The code you updated is sending information to store owner as well as other recipients too

Like i mentioned above if i want to send information to other e-mail address and "NOT STORE ADMIN"

then what should i do ?

I tried removing "var to = new MailAddress(emailAccount.Email, emailAccount.DisplayName);" and changed the code like this (removed "to")

MessageManager.InsertQueuedEmail(5, from, cc, bcc, subject, body2,
                        DateTime.UtcNow, 0, null, emailAccount.EmailAccountId);

But then i get error saying "it takes 10 arguments " ?

where am i going wrong ?

------ And ---

whenever i try to add any extra field , like State text box or any drop down menu or check box it gives an error saying:

"The field doesn't exists in the context "

But i did add the field in ascx page with the same ID name, where am i going wrong here ?

Thanks
This post/answer is useful
0
This post/answer is not useful

Please login or register
to vote for this post.

(click on this box to dismiss)
nopCommerce - Amazing Project
Thank You nopcommerce team !
Posted: November 19, 2010 at 12:02 AM Quote #30301
To use a different email address as the TO recipient, first add a new setting for the TO email address (Administraiton > Configuration > All Settings > Add new):
(specify the primary email address to receive the quotes as the value)
Name : RequestQuote.ToEmail 
Value:

Next, make the following change to file: Modules\RequestQuote.ascx.cs
After the line:
var to = new MailAddress(emailAccount.Email, emailAccount.DisplayName);
add the following:
string toEmail = SettingManager.GetSettingValue("RequestQuote.ToEmail", String.Empty).Trim();
if (string.IsNullOrEmpty(toEmail) == false)
{
    try
    {
        to = new MailAddress(toEmail);
    }
    catch (Exception)
    { }
}

Then recompile the solution.

This change will allow you to override the Admin default email account and use the one you specified in the setting. If the setting is not set or the setting is empty or the email address is malformed, then the default admin email address will be used (as a fail-safe). Using the three addresses you posted earlier, you would configure the settings with the following values:
Name : RequestQuote.ToEmail 
Value: [email protected]

Name : RequestQuote.BCCEmails
Value: [email protected]; [email protected]
---

As for the extra fields you are trying to add, can you post the code?

.
This post/answer is useful
0
This post/answer is not useful

Please login or register
to vote for this post.

(click on this box to dismiss)
Posted: November 19, 2010 at 9:56 AM Quote #30343
hello mb, thank you for correcting me with the above code.

And one more thing, i was able to make the code work for extra fields also.

The only thing that is left is that i am trying to provide an upload file option and i am getting errors, i have added the required code but still it is not working.

I uploaded my files here so that it will be easy for you to look at my code:

http://download360.mediafire.com/vik70uy2jueg/f0e3n7uajvanoly/RequestQuote2.zip]http://download360.mediafire.com/vik70uy2jueg/f0e3n7uajvanoly/RequestQuote2.zip

thank you
This post/answer is useful
0
This post/answer is not useful

Please login or register
to vote for this post.

(click on this box to dismiss)
nopCommerce - Amazing Project
Thank You nopcommerce team !
Posted: November 20, 2010 at 12:57 AM Quote #30374
If you want to add attachments to the email message, the MessageManager class needs to be updated with a new new method that can handle the attachments. You won't be able to use the MessageQueue though as it doesn't have the capability to store the attachments.

I've modified the code you posted for RequestQuote2 to include the three attachments in the quote request email message and to send the message directly since you can't use the message queue with attachments. Since the message doesn't go to the queue, I've added an error panel at the bottom that is displayed if an exception is thrown when sending the message (you can modify the error message in RequestQuote2.ascx). I've also modified the system log entry to include the quote details when an error occurs. Note that it doesn't keep the attachments, and the HTML tags are encoded, but it's better than losing the customer information if an error occurs -you could contact the customer directly to get the attachments (coupons) if needed. The error should only occur if your email isn't set up correctly in Administration or the mail server is down.

I've tested with sending a quote request with text files and images as attachments with no problems. I believe, by default, the maximum file size that can be uploaded is 4MB. You may have to alter the code if this isn't suitable.

Modified files (see the README.txt file):
http://www.mediafire.com/file/fk66j85cc5fggki/RequestQuote2_Update2.zip (for 1.80) (UPDATED)
http://www.mediafire.com/file/8xman3r1pcrfezo/RequestQuote2_190_updated.zip (for 1.90)  (UPDATED)

UPDATED:
Updated the control to better format the quote details in the error log (stripped HTML tags and bracketed field names) also fixed an error in your code for the DiscountCoupon DDL's selected value.

.
This post/answer is useful
0
This post/answer is not useful

Please login or register
to vote for this post.

(click on this box to dismiss)
Posted: November 22, 2010 at 9:20 AM Quote #30518
Hi mb,

thank you very much for your help, everything looks great.

2 things:

1) When we attach any file, the receiver of the request quote information gets the attach file but the name of the attach file changes and becomes the path of the person's computer who is sending that information. How to avoid that and keep the name of the attach file as it is ?

2) I tried sending file around 3mb but that results in an error msg. Where i can increase the size of the attachment files ? (I didn't file anything in the code)

thank you very much
super
This post/answer is useful
0
This post/answer is not useful

Please login or register
to vote for this post.

(click on this box to dismiss)
nopCommerce - Amazing Project
Thank You nopcommerce team !
Posted: November 22, 2010 at 5:10 PM Quote #30565
I didn't see the full path for the uploaded filenames in any of the test emails I sent, but you can make the following changes to get only the filename from a path:

Replace the following line (in RequestQuote2.ascx.cs):
    string fileName = AttachmentFile.PostedFile.FileName;
with:
    string fileName = Path.GetFileName(AttachmentFile.PostedFile.FileName);

and replace:
    string fileName = FileUpload1.PostedFile.FileName;
with:
    string fileName = Path.GetFileName(FileUpload1.PostedFile.FileName);

and replace:
    string fileName = FileUpload2.PostedFile.FileName;
with:
    string fileName = Path.GetFileName(FileUpload2.PostedFile.FileName);

---

The file upload max size is set with the following line in web.config:
    
<httpRuntime maxRequestLength="51200" requestValidationMode="2.0"/>

However, it is already set to 51200 KB (50MB). See the "maxRequestLength" attribute on the following page:
http://msdn.microsoft.com/en-us/library/e1f13641%28v=VS.100%29.aspx

Perhaps your web host has a lower limit set or your mail server may have a smaller max attachment size limit. It could also be the execution timeout limit is reached before the upload can complete -the default is 110 seconds. You can change it for the site with the "executionTimeout" attribute -see the previous MSDN link.

You can also set if for just the page by adding the following to RequestQuote2.ascx.cs:
    protected void Page_Init(object sender, EventArgs e)
    {
        // Set timeout to ten minutes
        Server.ScriptTimeout = 600;
    }

.
This post/answer is useful
0
This post/answer is not useful

Please login or register
to vote for this post.

(click on this box to dismiss)
Posted: November 23, 2010 at 3:15 PM Quote #30661
thank you mb for all your help.

Now i m getting the correct file name instead of filepath.

I noticed in the webconfig that it is defined as "51200" but I still get error message when i try to attach files more than 2 mb but i am doing all these things on my local machine (because i am in development phase). May be it will work on hosting server, does that make any difference ?

This is the error message i get: "There was an error in sending your quote request. Support has been notified with your contact information" which is defined in .ascx file

Thank you again for all your help and time, you are the best !
This post/answer is useful
0
This post/answer is not useful

Please login or register
to vote for this post.

(click on this box to dismiss)
nopCommerce - Amazing Project
Thank You nopcommerce team !
1 2 3 4 >
Premium support services
  • Dedicated premium support services provided by core developers are intended for persons who run mission critical websites, work on projects with tight deadlines, or want to get dedicated support.
Professional services
  • Want to open a new store? Want to take your store to the next level? Need a custom extension? We can customize nopCommerce to fit your store perfectly. Request a quote to get started.