Developer forum

Forum » Development » Accessing Order fields

Accessing Order fields

Dmitrij Jazel
Reply
Hi guys,
Wanted to know how can I access order fields that I setup in the order management center?
Lets say I have a checkout event, I access the order object, but how do I access it?

From eCommerce.Cart.OrderIsPassedToCheckoutHandlerArgs myArgs
I access order object. and can go through the list.
Using Dynamicweb.eCommerce.Orders.OrderField I can access the field, but cannot extract the value from it.
toString() returns "Dynamicweb.eCommerce.Orders.OrderField". 

This is how I am access it,
            var orderFields = myArgs.Order.OrderFields;

            foreach (Dynamicweb.eCommerce.Orders.OrderField field in orderFields)
            {
                if (field.Name == "Rekvnr")
                {
                    string s = field.ToString();
                    errorMessage("value "+ s);
                }  
            }
the solution should be reather simple, but I just can't find the value of the orderField if I am accessing it correctly.
Any suggestions? :-)

Regards,
Dmitrij


Replies

 
Imar Spaanjaars Dynamicweb Employee
Imar Spaanjaars
Reply
This post has been marked as an answer

Hi Dmitrij,

Take a look at the OrderFieldValues property of the Order class: http://developer.dynamicweb-cms.com/api/ecommerce/Dynamicweb~Dynamicweb.eCommerce.Orders.Order~OrderFieldValues.html


Cheers,

Imar
Votes for this answer: 0
 
Dmitrij Jazel
Reply
Thanks Imar,
Much appreciated as always :-)

solution code:
                using Dynamicweb.eCommerce.Orders;

                var orderFields = myArgs.Order.OrderFieldValues;

                foreach (OrderFieldValue fieldValue in orderFields)
                {
                    if (fieldValue.OrderField.Name == "FieldName")
                    {
                        string s = fieldValue.Value.ToString();
                        print("value of rekvnr: " + s);
                    }
                }


Dmitrij

 

You must be logged in to post in the forum