Developer forum

Forum » Development » Order delivery status update

Order delivery status update

Ivan Marijanović
Ivan Marijanović
Reply

Hi

I need to implement some functionality to get delivery status of shipment. 

I added the field on order DeliveryStatus and I am displaying it on list of orders. I have a code that will fetch me the new status of order.

How can I run this code each time the list of orders is opened? I need access to list of orders that I can get id from and that I can save new status.

Ivan


Replies

 
Viktor Letavin Dynamicweb Employee
Viktor Letavin
Reply
This post has been marked as an answer

Hi,

I think the only way you can achive this by adding "ribonbar addin" where you have the current orders from the list

something like 

 [AddInTarget(RibbonBarAddInTarget.eCom.OrderList)]
    public class MyAddin : RibbonBarAddIn
    {

        /// <summary>
        /// Initializes a new instance of the MyAddin class.
        /// </summary>
        public MyAddin(RibbonBar ribbon)
            : base(ribbon)
        {

        }

        public override void Load()
        {
            // To learn more about RibbonBarAddIns, check out: http://developer.dynamicweb-cms.com/documentation/for-developers/cms-extensibility/ribbon-bar.aspx

            RibbonBarGroup group = base.CreateDefaultContainer();
            RibbonBarButton button = new RibbonBarButton();
            group.Name = "My group";
        
            group.AddItem(button);

            // Access the DataContext which is a Order collection for this AddIn.
            IEnumerable(Of Order) orders = base.Ribbon.DataContext.DataSource as IEnumerable(Of Order);

            button.Text = "Icon";
            button.Image = Dynamicweb.Controls.Icons.Icon.Type.CheckDocument;
            // Alternatively, specify your own Image path:
            // button.ImagePath = "/Admin/SomeImage.png";

            button.Size = Dynamicweb.Controls.Icons.Icon.Size.Large;
            button.EnableServerClick = true;
            button.Click += button_Click;
            group.Active = false;
          
        }

        void button_Click(object sender, EventArgs e)
        {
           // Handle click here           

        }

    }

This is just sketch, but I hope that will help.

 

BR, Viktor.

Votes for this answer: 1
 
Vladimir Shushunov Dynamicweb Employee
Vladimir Shushunov
Reply

Hi guys,
I want to add a small clarification: the type of DataSource  for OrderList addin was changed to Lazy<IEnumerable<Order>>;
This was done to improve performance.

So now to access to data context use code:

            var orders = base.Ribbon.DataContext.DataSource as Lazy<IEnumerable<Order>>;
            if (orders != null && orders.Value != null)
            {
                /// process orders.Value
            }
 
Best regards,
Vladimir

 

You must be logged in to post in the forum