Product templates and customer fields
Product templates and customer fields
Hello,
I am using product templates to obtain special instructions from the customer (if needed).
I don't like how regardless of whether the customer enters information in the field(s) or not it still shows the field name in the basket when they add an item to the basket.
Is there anyway to have it so that if the field is left blank (null) then the field name is not added to the basket?
Thank you.
I am using product templates to obtain special instructions from the customer (if needed).
I don't like how regardless of whether the customer enters information in the field(s) or not it still shows the field name in the basket when they add an item to the basket.
Is there anyway to have it so that if the field is left blank (null) then the field name is not added to the basket?
Thank you.
AC 7.0.3 build 13937
Re: Product templates and customer fields
Edit your ConLib/Utility/MiniBasketItemDetail.ascx.cs file and locate following code
and then change it as below
You may need a very similar change in ConLib/Utility/OrderItemDetail.ascx.cs and ConLib/Utility/BasketItemDetail.ascx.cs file as well for other potential locations.
Code: Select all
private BasketItemInputCollection GetCustomerInputs()
{
BasketItemInputCollection inputs = new BasketItemInputCollection();
foreach (BasketItemInput input in _BasketItem.Inputs)
{
if ((input.InputField != null) && (!input.InputField.IsMerchantField))
inputs.Add(input);
}
return inputs;
}
Code: Select all
private BasketItemInputCollection GetCustomerInputs()
{
BasketItemInputCollection inputs = new BasketItemInputCollection();
foreach (BasketItemInput input in _BasketItem.Inputs)
{
if ((input.InputField != null) && (!input.InputField.IsMerchantField) && !string.IsNullOrEmpty(input.InputValue))
inputs.Add(input);
}
return inputs;
}
Re: Product templates and customer fields
Ohhh wow! That small change in code makes such a difference.
I wished they would put that in a future release so I don't have to have custom code.
I can't imagine anyone wanting to see the Field Name if nothing is entered.
I changed the BasketItemDetail file because it was just like the minibasket file but the OrderItemsDetail I am afraid to touch because it looks quite different and I don't want to break any code.
If anyone has time to help with that file I would certainly be grateful.
Thanks Mazhar!
I wished they would put that in a future release so I don't have to have custom code.
I can't imagine anyone wanting to see the Field Name if nothing is entered.
I changed the BasketItemDetail file because it was just like the minibasket file but the OrderItemsDetail I am afraid to touch because it looks quite different and I don't want to break any code.
If anyone has time to help with that file I would certainly be grateful.
Thanks Mazhar!
AC 7.0.3 build 13937
Re: Product templates and customer fields
A blank space after "Special Instructions" on the email receipt can prompt the buyer to email an important note which may prevent an uncomfortable phone call once the product arrives.draneb wrote: I can't imagine anyone wanting to see the Field Name if nothing is entered.
I'd prefer to have "None" placed there as the default text just make it perfectly clear that instructions were not entered at the time of the order.
Mazhar, is this possible?
Re: Product templates and customer fields
Yep possiable, edit your App_Code/ProductHelper.cs file and locate following code block
and then change it as below
Now when collecting customer input if application found it empty it will place none in value.
Code: Select all
//ONLY LOOK FOR CUSTOMER INPUT FIELDS
if (!input.IsMerchantField)
{
//SEE IF WE CAN LOCATE THE CONTROL
WebControl inputControl = (WebControl)PageHelper.RecursiveFindControl(container, input.UniqueId);
if (inputControl != null)
{
BasketItemInput itemInput = new BasketItemInput();
itemInput.InputFieldId = input.InputFieldId;
itemInput.InputValue = input.GetControlValue(inputControl);
item.Inputs.Add(itemInput);
}
}
Code: Select all
//ONLY LOOK FOR CUSTOMER INPUT FIELDS
if (!input.IsMerchantField)
{
//SEE IF WE CAN LOCATE THE CONTROL
WebControl inputControl = (WebControl)PageHelper.RecursiveFindControl(container, input.UniqueId);
if (inputControl != null)
{
BasketItemInput itemInput = new BasketItemInput();
itemInput.InputFieldId = input.InputFieldId;
itemInput.InputValue = input.GetControlValue(inputControl);
if (string.IsNullOrEmpty(itemInput.InputValue))
itemInput.InputValue = "none";
item.Inputs.Add(itemInput);
}
}
Re: Product templates and customer fields
Hello,
I changed the BasketItemDetail file because it was just like the minibasket file and those work great, but the OrderItemsDetail.ascx.cs file I am afraid to touch because it looks quite different and I don't want to break any code. There is mention of Wishlist, Kits, Gift Wrap, Gift Message.... wheewww, that file makes my brain hurt.
This would be to hide the Custom Field if no text was entered by the user.
If anyone has time to help with the code for that file I would certainly be grateful. If you are a programmer and are for hire send me a message.
Thank you!
I changed the BasketItemDetail file because it was just like the minibasket file and those work great, but the OrderItemsDetail.ascx.cs file I am afraid to touch because it looks quite different and I don't want to break any code. There is mention of Wishlist, Kits, Gift Wrap, Gift Message.... wheewww, that file makes my brain hurt.
This would be to hide the Custom Field if no text was entered by the user.
If anyone has time to help with the code for that file I would certainly be grateful. If you are a programmer and are for hire send me a message.
Thank you!
AC 7.0.3 build 13937
Re: Product templates and customer fields
Locate following code block in your ConLib/Utiltiy/OrderItemDetails.ascx.cs file
and then change it to as below
Code: Select all
InputList.DataSource = _OrderItem.Inputs;
InputList.DataBind();
Code: Select all
OrderItemInputCollection inputsCollection = new OrderItemInputCollection();
foreach (OrderItemInput input in _OrderItem.Inputs)
if (!string.IsNullOrEmpty(input.InputValue))
inputsCollection.Add(input);
InputList.DataSource = inputsCollection;
InputList.DataBind();
Re: Product templates and customer fields
As usual, thank you Mazhar!
Where does that file remove the mention of the custom field?
I just wanted to make sure the change worked.
I placed a test order and the only other place I see mention of it for now is in the Admin.
I am wondering if I should remove it there as well and if so what file that would be in?
(viewing order in admin)
Thanks again.
Where does that file remove the mention of the custom field?
I just wanted to make sure the change worked.
I placed a test order and the only other place I see mention of it for now is in the Admin.
I am wondering if I should remove it there as well and if so what file that would be in?
(viewing order in admin)
Thanks again.
AC 7.0.3 build 13937
Re: Product templates and customer fields
Hmm for admin side you need to do very same thing in Website/Admin/UserControls/OrderItemDetail.ascx.csfile. Edit it and locate
and replace it with
Code: Select all
InputList.DataSource = _OrderItem.Inputs;
InputList.DataBind();
Code: Select all
OrderItemInputCollection inputsCollection = new OrderItemInputCollection();
foreach (OrderItemInput input in _OrderItem.Inputs)
if (!string.IsNullOrEmpty(input.InputValue))
inputsCollection.Add(input);
InputList.DataSource = inputsCollection;
InputList.DataBind();
Re: Product templates and customer fields
Mazhar,
I have one more question regarding this terrific project
Everything is working great so far. But there is one area I hadn't experimented with - the Wishlist.
So if I add an item without special instructions to My Wishlist it still shows the Field Name(s).
Is there a place where that can be fixed as well?
Thank you!
I have one more question regarding this terrific project

Everything is working great so far. But there is one area I hadn't experimented with - the Wishlist.
So if I add an item without special instructions to My Wishlist it still shows the Field Name(s).
Is there a place where that can be fixed as well?
Thank you!
AC 7.0.3 build 13937
Re: Product templates and customer fields
For this try to edit ConLib/MyWishlistPage.ascx file and lcoate following line of code
and update it as below
finally add following method to its code file
Code: Select all
<asp:DataList ID="InputList" runat="server" DataSource='<%# Eval("Inputs") %>'>
Code: Select all
<asp:DataList ID="InputList" runat="server" DataSource='<%# GetInputs(Eval("Inputs")) %>'>
Code: Select all
protected WishlistItemInputCollection GetInputs(Object dataItem)
{
WishlistItemInputCollection inputs = (WishlistItemInputCollection)dataItem;
WishlistItemInputCollection notEmptyInputs = new WishlistItemInputCollection();
foreach (WishlistItemInput input in inputs)
if (!String.IsNullOrEmpty(input.InputValue))
notEmptyInputs.Add(input);
return notEmptyInputs;
}