Page 1 of 1
Product templates and customer fields
Posted: Mon May 25, 2009 9:00 pm
by draneb
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.
Re: Product templates and customer fields
Posted: Tue May 26, 2009 4:24 am
by mazhar
Edit your ConLib/Utility/MiniBasketItemDetail.ascx.cs file and locate following code
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;
}
and then change it as below
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;
}
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.
Re: Product templates and customer fields
Posted: Tue May 26, 2009 6:09 am
by draneb
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!
Re: Product templates and customer fields
Posted: Tue May 26, 2009 6:33 am
by William M
draneb wrote:
I can't imagine anyone wanting to see the Field Name if nothing is entered.
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.
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
Posted: Tue May 26, 2009 7:20 am
by mazhar
Yep possiable, edit your App_Code/ProductHelper.cs file and locate following code block
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);
}
}
and then change it as below
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);
}
}
Now when collecting customer input if application found it empty it will place
none in value.
Re: Product templates and customer fields
Posted: Fri May 29, 2009 8:53 pm
by draneb
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!
Re: Product templates and customer fields
Posted: Sat May 30, 2009 1:30 am
by mazhar
Locate following code block in your
ConLib/Utiltiy/OrderItemDetails.ascx.cs file
Code: Select all
InputList.DataSource = _OrderItem.Inputs;
InputList.DataBind();
and then change it to as below
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
Posted: Sat May 30, 2009 3:07 pm
by draneb
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.
Re: Product templates and customer fields
Posted: Mon Jun 01, 2009 3:45 am
by mazhar
Hmm for admin side you need to do very same thing in
Website/Admin/UserControls/OrderItemDetail.ascx.csfile. Edit it and locate
Code: Select all
InputList.DataSource = _OrderItem.Inputs;
InputList.DataBind();
and replace it with
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
Posted: Sat Jul 04, 2009 5:26 pm
by draneb
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!
Re: Product templates and customer fields
Posted: Mon Jul 06, 2009 3:51 am
by mazhar
For this try to edit ConLib/MyWishlistPage.ascx file and lcoate following line of code
Code: Select all
<asp:DataList ID="InputList" runat="server" DataSource='<%# Eval("Inputs") %>'>
and update it as below
Code: Select all
<asp:DataList ID="InputList" runat="server" DataSource='<%# GetInputs(Eval("Inputs")) %>'>
finally add following method to its code file
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;
}