Adding a salutation to Billing and Shipping addresses
Adding a salutation to Billing and Shipping addresses
Is there a way to add a required field for Salutation (Mr., Mrs. etc.) on the checkout pages? Just realized that there is not a field for this and we will have correspondence going out and need to know how to address our customers.
Thanks.
Thanks.
Re: Adding a salutation to Billing and Shipping addresses
Yes its possible, address table contains an unused field Nickname, you can make use of that field to contain this info. For example here is the code required for billing address you can do very same thing for shipping address as well.
Edit ConLib/OnePageCheckout.ascx file and locate following code
and then change it as below
Now edit ConLib/OnePageCheckout.ascx.cs file and locate following code
and change it as below
Locate following code
and change it as below
Edit ConLib/OnePageCheckout.ascx file and locate following code
Code: Select all
<tr>
<th class="rowHeader">
<asp:Label ID="BillToFirstNameLabel" runat="server" Text="First Name:" AssociatedControlID="BillToFirstName" EnableViewState="false"></asp:Label>
</th>
<td>
<asp:TextBox ID="BillToFirstName" runat="server" EnableViewState="false" Width="120px" MaxLength="20" ValidationGroup="OPC"></asp:TextBox>
<asp:RequiredFieldValidator ID="BillToFirstNameRequired" runat="server" Text="*"
ErrorMessage="First name is required." Display="Static" ControlToValidate="BillToFirstName"
EnableViewState="False" SetFocusOnError="false" ValidationGroup="OPC"></asp:RequiredFieldValidator>
</td>
</tr>
Code: Select all
<tr>
<th class="rowHeader">
<asp:Label ID="Label1" runat="server" Text="Salutation:" AssociatedControlID="BillToSalutation" EnableViewState="false"></asp:Label>
</th>
<td>
<asp:TextBox ID="BillToSalutation" runat="server" EnableViewState="false" Width="120px" MaxLength="20" ValidationGroup="OPC"></asp:TextBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidatorSalutation" runat="server" Text="*"
ErrorMessage="Salutation is required." Display="Static" ControlToValidate="BillToSalutation"
EnableViewState="False" SetFocusOnError="false" ValidationGroup="OPC"></asp:RequiredFieldValidator>
</td>
</tr>
<tr>
<th class="rowHeader">
<asp:Label ID="BillToFirstNameLabel" runat="server" Text="First Name:" AssociatedControlID="BillToFirstName" EnableViewState="false"></asp:Label>
</th>
<td>
<asp:TextBox ID="BillToFirstName" runat="server" EnableViewState="false" Width="120px" MaxLength="20" ValidationGroup="OPC"></asp:TextBox>
<asp:RequiredFieldValidator ID="BillToFirstNameRequired" runat="server" Text="*"
ErrorMessage="First name is required." Display="Static" ControlToValidate="BillToFirstName"
EnableViewState="False" SetFocusOnError="false" ValidationGroup="OPC"></asp:RequiredFieldValidator>
</td>
</tr>
Code: Select all
BillToFirstName.Text = billingAddress.FirstName;
Code: Select all
BillToSalutation.Text = billingAddress.Nickname;
BillToFirstName.Text = billingAddress.FirstName;
Code: Select all
billingAddress.FirstName = StringHelper.StripHtml(BillToFirstName.Text);
Code: Select all
billingAddress.Nickname = StringHelper.StripHtml(BillToSalutation.Text);
billingAddress.FirstName = StringHelper.StripHtml(BillToFirstName.Text);
Re: Adding a salutation to Billing and Shipping addresses
Thank you so much. It works perfectly. If I do want to add an additional third field, is it very complicated? I've already tried adding it to the the database (Address3) and modifying the code but get the following error.
[[ConLib:OnePageCheckout]] d:\commerce\ConLib\OnePageCheckout.ascx.cs(696): error CS0117: 'CommerceBuilder.Users.Address' does not contain a definition for 'Address3'
I am not sure how to edit 'CommerceBuilder.Users.Address' or even if it is possible.
[[ConLib:OnePageCheckout]] d:\commerce\ConLib\OnePageCheckout.ascx.cs(696): error CS0117: 'CommerceBuilder.Users.Address' does not contain a definition for 'Address3'
I am not sure how to edit 'CommerceBuilder.Users.Address' or even if it is possible.
-
- Lieutenant, Jr. Grade (LT JG)
- Posts: 50
- Joined: Mon Jul 02, 2007 9:37 pm
- Location: Chicago, IL
- Contact:
Re: Adding a salutation to Billing and Shipping addresses
Hi CASE,
Adding Address3 will not work like that. As far as I know, you will need to create a custom query that saves the Address3 value to the database in to a custom database field. The reason Nickname worked by simply adding those two lines of code is because that is a standard Ablecommerce field.
Adding Address3 will not work like that. As far as I know, you will need to create a custom query that saves the Address3 value to the database in to a custom database field. The reason Nickname worked by simply adding those two lines of code is because that is a standard Ablecommerce field.
Re: Adding a salutation to Billing and Shipping addresses
Instead of adding a brand new field for Address 3 what about trying following work around. The concept is to make use of Nickname field to accommodate two values separated by some special character for example | pipe sign. You can have two different UI elements for input but in back end when trying to save data concatenate values from both text boxes something like
Similarly when it comes to show the saved information you can first split Nickname value over | sign and then update respective UI elements to show that information. For example
If nick name field size seem small, you can increase it to accommodate both values.
Code: Select all
address.Nickname = text1.Text+"|"+text2.Text;
Code: Select all
string[] values = address.Nickname.Split('|');
text1.Text = values[0];
text2.Text = values[1];
Re: Adding a salutation to Billing and Shipping addresses
Thank you. We've decided to go without the third field.
On the payment options page in the checkout, where the shipping and billing addresses are listed out, it doesn't show the two added fields. If I select edit on this page, the extra fields do display on the edit address page. Is there something else that I need to edit to make these fields show?
In the attached image, both billing and shipping should show a title and address 3 field.
On the payment options page in the checkout, where the shipping and billing addresses are listed out, it doesn't show the two added fields. If I select edit on this page, the extra fields do display on the edit address page. Is there something else that I need to edit to make these fields show?
In the attached image, both billing and shipping should show a title and address 3 field.