public override void OnNotify(string notification, NotificationArgs args) { if (Global.IsIntegrationActive && Connector.IsWebServiceConnectionAvailable()) { //Used to load the cart and apply the discount after the user logged-in and has not empty cart var myArgs = (Dynamicweb.Notifications.Standard.User.OnExtranetLoginArgs)args; var order = Dynamicweb.Ecommerce.Common.Context.Cart; if (myArgs.User != null) { UrlHandler.Instance.ClearCachedUrl(); Dynamicweb.Ecommerce.Integration.ErpResponseCache.ClearAllCaches(); PrepareProductInfoProvider.ClearUserCache(); //check if user has updates CheckUser(myArgs.User); } if (order != null && order.IsCart && EnabledAndActive()) { if (Global.EnableCartCommunication(order.Complete)) { OrderHandler.UpdateOrder(order, LiveIntegrationSubmitType.LiveOrderOrCart); } else { CheckOrderPrices(order, "OnExtranetLogin"); } } } }
/// <summary> /// Clears and sets the product information in Dynamicweb for all the products in the order. /// </summary> /// <param name="order"></param> protected void SetProductInformation(Dynamicweb.Ecommerce.Orders.Order order) { if (order == null) { return; } // clear product cache to ensure refresh from ERP Dynamicweb.Ecommerce.Integration.ErpResponseCache.ClearAllCaches(); PrepareProductInfoProvider.ClearUserCache(); // read all products in the order var productsToUpdate = order.OrderLines.Where(ol => ol.IsProduct()).Select(ol => ol.Product); if (productsToUpdate != null && productsToUpdate.Any()) { Logging.Logger.Instance.Log(Logging.ErrorLevel.DebugInfo, string.Format("Reload prices. products #{0}", productsToUpdate.Count())); User orderUser = User.GetUserByID(order.CustomerAccessUserId); SetProductsInfo(productsToUpdate.ToList(), orderUser); } }