Set a value for Customer Template Field

For general questions and discussions specific to the AbleCommerce 7.0 Asp.Net product.
Post Reply
joebeazelman
Lieutenant (LT)
Lieutenant (LT)
Posts: 78
Joined: Wed Mar 05, 2008 11:27 am

Set a value for Customer Template Field

Post by joebeazelman » Thu Nov 20, 2008 11:01 am

I have a template that contains the following customer fields: width and height, etc. I don't want the customer to actually enter in these values because they are calculated from a user control. I want to take the values from my user control and enter them into these template fields. The reason for this is so that these fields show up in the order. Is there a way to reference these controls by name? The only way I can conceive of doing this is by looping throw the _Product.ProductTemplate.InputFields. Here's my code I adapted from ProductHelper.cs:

public void FillCustomerTemplateFields()
{
ProductTemplate template = _Product.ProductTemplate;
// COLLECT ANY ADDITIONAL INPUTS
if (template != null)
{
foreach (InputField input in template.InputFields)
{
if (!input.IsMerchantField)
{
switch (input.Name)
{
case "Length":
TextBox test = (TextBox)phOptions.FindControl(input.UniqueId);
test.Text = "value";
break;
}
}
}
}
}

User avatar
mazhar
Master Yoda
Master Yoda
Posts: 5084
Joined: Wed Jul 09, 2008 8:21 am
Contact:

Re: Set a value for Customer Template Field

Post by mazhar » Thu Nov 20, 2008 12:02 pm

No i think this is the best way to do this in this case.

joebeazelman
Lieutenant (LT)
Lieutenant (LT)
Posts: 78
Joined: Wed Mar 05, 2008 11:27 am

Re: Set a value for Customer Template Field

Post by joebeazelman » Thu Nov 20, 2008 9:50 pm

Thanks Mazhar.

Currently, the page displays all of the customer fields, I want them to disappear. I tried to make phOptions invisible, but it also makes the Options and Variants invisible. Is there a way to make them not show up, but still be able to store and retrieve values from them?

User avatar
mazhar
Master Yoda
Master Yoda
Posts: 5084
Joined: Wed Jul 09, 2008 8:21 am
Contact:

Re: Set a value for Customer Template Field

Post by mazhar » Fri Nov 21, 2008 5:10 am

You can set the customer input control visiability to hidden in the BuildProductChoices function of PageHelper class. Locate the following line of code in the method

Code: Select all

phChoices.Controls.Add(o);
and make it look like

Code: Select all

o.Visible = false;
phChoices.Controls.Add(o);

User avatar
bha
Lieutenant, Jr. Grade (LT JG)
Lieutenant, Jr. Grade (LT JG)
Posts: 44
Joined: Tue Mar 11, 2008 6:04 pm

Re: Set a value for Customer Template Field

Post by bha » Mon Jun 08, 2009 6:08 pm

All good stuff here for customer template fields. Put'em to good use.

Question:
For a customer that needs to enter multiple orderitems with the same customer field (orderiteminput) values, what is the best way to copy all the customer input values from the previous basket item into the new product helper control?

This is being done under /Admin/Orders/PlaceOrder1.aspx as the orderiteminput values are copied to the controls as long as the product template is the same. I don't see the copy function but the ShowProductForm(Product product) populates the input fields, which is exactly what I would need from the store's basket.

I can add a button such as <Create Duplicate Lineitem> but assistance or hints on the copy code would be greatly appreciated! (I understand that there is a code for reorder, but the key here is to have the customer be able to edit as well - such as changing just the number on a serialized "dazzle01, dazzle02, etc...")

Example:
Basket:
SKU = Gadget1
CustomWidth = 20
CustomLength = 10
Serialization = Dazzle01

When <Create Duplicate LineItem> is clicked, Show Product page is displayed with BuyProductDialog populated with values from previous orderitem.

BuyProductDialog:
SKU = Gadget1
CustomWidth = 20
CustomLength = 10
Serialization = Dazzle01

and then Dazzle01 can be changed to Dazzle02

Thanks,
Bruce.

Post Reply