Dynamicweb 8 Documentation
OrderFieldValue Class
Members  Example 

This class saves the new values for OrderField
Object Model
OrderFieldValue ClassOrderField Class
Syntax
'Declaration
 
<SerializableAttribute()> 
Public Class OrderFieldValue 
[SerializableAttribute()] 
public class OrderFieldValue 
Example
The example shows how you can manipulate the information in custom order fields. The following shows an example where a class subscribes to the notification Dynamicweb.Notifications.eCommerce.Order.Steps.Completed, which can be used to manage the custom order field information.
[Subscribe(Dynamicweb.Notifications.eCommerce.Order.Steps.Completed)]
public class OrderCompleteNotificationSubscriber : NotificationSubscriber
{
    public override void OnNotify(string notification, object[] args)
    {
        bool sendNewsletter = false;
        string emailAddress = "";
 
        Dynamicweb.eCommerce.Orders.Order MyOrder = (Dynamicweb.eCommerce.Orders.Order)args[0];
        OrderFieldValueCollection ofvCol = MyOrder.OrderFieldValues;
        foreach (OrderFieldValue orderField in ofvCol)
        {
            if (orderField.OrderField.SystemName.ToLower()  == "newsletteremail")
            {
               emailAddress = orderField.Value.ToString();
               sendNewsletter = true;
               break;
            }
        }
 
        if (sendNewsletter)
        { 
           SendEmail( emailAddress, "Order is completed" );    
        }
 
    }
}
class MyPage : System.Web.UI.Page
{
   public void CustomOrderFields(Order order)
   {
       FieldTypeCollection fieldTypes = FieldType.getFieldTypes();
       foreach (OrderFieldValue ofv in order.OrderFieldValues)
       {
           FieldType ft = fieldTypes.GetFieldType(ofv.OrderField.TypeID);

           string reqValue = Base.ChkString(Base.Request(ofv.OrderField.SystemName));
           switch (ft.DWName.ToLower())
           {
               case "text":
               case "largetext":
               case "integer":
               case "double":
                   ofv.Value = Base.ChkString(Base.Request(ofv.OrderField.SystemName, false));
                   break;
               case "checkbox":
                   ofv.Value = !string.IsNullOrEmpty(reqValue);
                   break;
               case "date":
               case "datetime":
                   ofv.Value = Dates.ParseAsDate(ofv.OrderField.SystemName);
                   break;
               case "link":
                   ofv.Value = reqValue;
                   break;
               case "filemanager":
                   ofv.Value = reqValue;
                   break;
               default:
                   break;
           }
       }
   }
}
Inheritance Hierarchy

System.Object
   Dynamicweb.eCommerce.Orders.OrderFieldValue

Requirements

Target Platforms: Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

See Also

Reference

OrderFieldValue Members
Dynamicweb.eCommerce.Orders Namespace

Send Feedback