Hi there,
I am trying to implement a custom order line field as a checkbox. I added the following code to my product template
<!--@If(Ecom:Product.OrderLineField.SystemName=='PrintBold')--> <input
id="Checkbox1" type="checkbox"
name="<!--@Ecom:Product.OrderLineField.InputTextFieldName-->" /> <!--@EndIf-->
<!--@If Not(Ecom:Product.OrderLineField.SystemName=='PrintBold')-->
<!--@Ecom:Product.OrderLineField.InputTextField--><br /> <!--@EndIf-->
This works great and assigns the value 'on' to the field when the user checks the checkbox.
I use similar code in my Cart template to let a user update the field, but I run into problems when the user unchecks the checkbox at some stage. Here's the flow where it goes wrong:
1. User views product, checks the checkbox and clicks Add to cart.
2. User views the cart. Using If Statements with contains / startswith I can preselect the checkbox just fine.
3. User clears the checkbox and clicks next to go to the Information step
4. User clicks back to view the cart again. The checkbox is now checked again.
Between step 3 and 4, Dynamicweb doesn't successfully update the custom order line field. I guess it loops through the Request.Form collection looking for fields that start with OrderLineFieldValue and then find the associated order line field, rather than looping through the available order line fields and trying to find the associated form field values.
Since a checkbox doesn't submit itself when it's unchecked, Dynamicweb doesn't see this field and doesn't update the order line field to an empty string.
Could / should this be fixed? I am currently working around it by adding an additional hidden field with the same name. This field is always empty, but at least gets submitted to the server. This works, but leads to an additional comma in the field’s value (e.g. 'on,' instead of 'on').
Any suggestions for a better solution?
Imar