Disable Zip code requirement

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
14 years ago
For shipping nopCommerce makes zip/post code a required field.

unfortunately, Ireland (where most of the buyers will be) has no zip or post codes. Some buyers will be savvy enough to enter a false code, but it is confusing and messy for users, and the warning that this field is empty is too subtle.

Is there any way that I can disable the requirement to complete this field?

thanks
14 years ago
bump
14 years ago
Hi,

What you could do is,

Goto modules/AddressDisplay.ascx and remove;

<asp:Literal ID="lZipPostalCode" runat="server"></asp:Literal>

Then modules/AddressDisplay.ascx.cs and comment out this line;

//this.lZipPostalCode.Text = Server.HtmlEncode(address.ZipPostalCode);


Then Goto modules/AddressEdit.ascx and remove;

   <tr>
        <td>
            <%=GetLocaleResourceString("Address.ZipPostalCode")%>:
        </td>
        <td>
            <nopCommerce:SimpleTextBox runat="server" ID="txtZipPostalCode" ErrorMessage="<% $NopResources:Address.ZipPostalCodeIsRequired %>">
            </nopCommerce:SimpleTextBox>
        </td>
    </tr>



Then modules/AddressEdit.ascx.cs and do this;

in Page_load event:

string txtZipPostalCode = "NULL";
txtZipPostalCode = string.Empty;


instead of

txtZipPostalCode.Text = string.Empty;


Then Public Address:

address.ZipPostalCode = "NULL";
instead of
address.ZipPostalCode = txtZipPostalCode.Text.Trim();


Then

string txtZipPostalCode = "NULL";
txtZipPostalCode = address.ZipPostalCode;


insead of

txtZipPostalCode.Text = address.ZipPostalCode;


and then in Validation group comment out this line;

//txtZipPostalCode.ValidationGroup = value;


This should sort out the issue, you will also need to comment out on registration page adn a few other page, but you need to give a fake value as the databse does not allow null fields..

But this is not hte best way todo this, you could use the DropDown list and put post code in a panel then use a if statement to hide postcode on country selection..

hope this helps, mike.. If you get any issues please tell me.
14 years ago
Could you kindly explain more about how to sort it out by using drop down list? Which files should be modify?

It would be great if we can list down something like "n/a" in the drop down list for ZipPostalCode!

Greatly appreciate for your help!
14 years ago
Or is there any simple way to put default value like "n/a" in to the ZipPostalCode field?

Thanks a ton!
14 years ago
Hi

Thanks for your reply. Unfortunately, this didn't work. I am new to all this so maybe I'm missing some presumed knowledge.

I think that the error is somewhere in the AddressEdit.ascx.cs instructions, because it says

Then 

string txtZipPostalCode = "NULL";
txtZipPostalCode = address.ZipPostalCode;


insead of

txtZipPostalCode.Text = address.ZipPostalCode;


Actually there is no line

txtZipPostalCode.Text = address.ZipPostalCode;


but there is a line

this.txtZipPostalCode.Text = address.ZipPostalCode;


Is the this. supposed to go in front of either or both the two replacement lines you suggest?

Thanks for your help
14 years ago
For clarity, what I am trying to do is make the Zip code optional. I don't want to remove the possibility of the customer supplying it, just the requirement for them to do so.
14 years ago
change the validation group of zip code and that's all i think
13 years ago
Disabling the Zip coe requirement was quite a trouble, in my case I needed to eliminate the field from the form so I did the following steps:

Eliminate txtZipPostalCode from AddressEdit.ascx (both markup and code behind)

In the CustomerManager.cs class look for the use of the address.ZipPostalCode property and comment where it's used for validation, such as the method CanUseAddressAsBillingAddress, if you don't do it it will consider an empty ZIP as invalid.
13 years ago
you can disable the zip code requirement in admin

go to configuration-->global settings


look at the customer profiles tab


-hayden
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.