Developer forum

Forum » Development » Custom Orderline fields

Custom Orderline fields


Reply

 

I'm trying to get hold of the orderline customfields during the

Cart.Line.Added incidenthandler. but fails.

 

Do you have an example ?

 

/Lars


Replies

 
Reply

I used this example for demonstrating how to programatically enter data in custom orderline fields at the last Tech Review. Please note that until the most resent build the Cart.LineAdded notification didn't work, so please make sure that you're running version the latest version.

 

using Dynamicweb.Frontend;
using Dynamicweb.Extensibility;

namespace CustomModules
{
    [Subscribe(Dynamicweb.Notifications.eCommerce.Order.Steps.Completed)]
    public class NotificationSubscriber2 : NotificationSubscriber
    {

        public override void OnNotify(string notification, object[] args)
        {
            Dynamicweb.eCommerce.Orders.Order MyOrder = (Dynamicweb.eCommerce.Orders.Order)args[0];
            foreach (Dynamicweb.eCommerce.Orders.OrderLine line in MyOrder.OrderLines)
            {
                foreach (Dynamicweb.eCommerce.Orders.OrderLineFieldValue field in line.OrderLineFieldValues)
                {
                    if (field.OrderLineFieldSystemName.ToLower() == "dispatchestimate")
                    {
                        field.Value = "Week 45";
                        line.Save();
                        break;
                    }
                }
            }
        }
    }
}

 

 

You must be logged in to post in the forum