public void Process(RestoreCartArgs args) { if (args.CartItems == null || !args.CartItems.Any()) { return; } if (args.ShoppingCart.ShoppingCartLines.Any() && !args.ShoppingCart.ShoppingCartLines.Select(s => s.Product.Code).Except(args.CartItems.Keys).Any()) { return; } if (args.ShoppingCart.ShoppingCartLines.Any()) { args.Result.CartMerged = true; } var restoreProductArgs = new RestoreCartProductArgs { CartManager = args.CartManager, ShoppingCart = args.ShoppingCart, StockManager = args.StockManager, ProductRepository = args.ProductRepository, Result = args.Result }; foreach (var product in args.CartItems) { restoreProductArgs.ProductCode = product.Key; restoreProductArgs.Quantity = product.Value; RestoreCartProductPipeline.Run(restoreProductArgs); } }
public void Process(RestoreCartArgs args) { if (!string.IsNullOrEmpty(args.CouponCode) && !args.ShoppingCart.CouponCodes.Any()) { args.CouponCode.Split("|".ToCharArray()).ToList().ForEach(c => args.ShoppingCart.AddCouponCode(c)); } }
public void Process(RestoreCartArgs args) { var cookie = new ShoppingCartCookie(); if (args.CartItems == null) { args.CartItems = cookie.CartItems; } else { foreach (var item in cookie.CartItems) { if (!args.CartItems.ContainsKey(item.Key)) { args.CartItems.Add(item.Key, item.Value); } else if (args.CartItems[item.Key] < item.Value) { args.CartItems[item.Key] = item.Value; } } } if (string.IsNullOrEmpty(args.CouponCode)) { args.CouponCode = cookie.CouponCode; } }
public void Process(RestoreCartArgs args) { if (CartPersistenceContext.PersistenceInitialized && !args.ForceRestore) { args.AbortPipeline(); return; } }
public void Process(RestoreCartArgs args) { if (!CartPersistenceContext.CartUpdatedEventInitialized) { args.ShoppingCart.CartChanged += CartUpdatedHandler.CartUpdated; CartPersistenceContext.CartUpdatedEventInitialized = true; } }
public void Process(RestoreCartArgs args) { if (HttpContext.Current == null || !args.Result.AttemptedRestore) { return; } HttpContext.Current.Session[RestoreCartResult.SessionKey] = args.Result; }
public void Process(RestoreCartArgs args) { Assert.ArgumentNotNull(args.ShoppingCart, "ShoppingCart"); Assert.ArgumentNotNull(args.CartManager, "CartManager"); Assert.ArgumentNotNull(args.ProductRepository, "ProductRepository"); Assert.ArgumentNotNull(args.StockManager, "StockManager"); Assert.ArgumentNotNull(args.CustomerManager, "CustomerManager"); Assert.ArgumentNotNull(args.Result, "Result"); }
public void Process(RestoreCartArgs args) { if (CartPersistenceContext.CustomerRestoreStrategy == CustomerRestoreStrategy.None) { return; } var user = args.CustomerManager.CurrentUser; if (user == null || string.IsNullOrEmpty(user.NickName) || Sitecore.Context.Domain.IsAnonymousUser(user.NickName)) { return; } if (CartPersistenceContext.CustomerRestoreStrategy == CustomerRestoreStrategy.OverwriteIfEmpty && args.CartItems.Any() || args.ShoppingCart.ShoppingCartLines.Any()) { return; } if (CartPersistenceContext.CustomerRestoreStrategy == CustomerRestoreStrategy.Overwrite) { args.CartItems.Clear(); using (args.ShoppingCart.DisableEvents(false)) { args.ShoppingCart.ShoppingCartLines.Clear(); } } var customerCoupon = user.CustomProperties[PersistToCustomer.CouponCodeKey]; if (!string.IsNullOrEmpty(customerCoupon) && customerCoupon != PersistToCustomer.EmptyCart) { args.CouponCode = user.CustomProperties[PersistToCustomer.CouponCodeKey]; } var customerCart = user.CustomProperties[PersistToCustomer.CartItemsKey]; if (!string.IsNullOrEmpty(customerCart) && customerCart != PersistToCustomer.EmptyCart) { if (args.CartItems == null) { args.CartItems = new Dictionary <string, uint>(); } var cartItems = user.CustomProperties[PersistToCustomer.CartItemsKey]; var products = cartItems.Split(','); foreach (var product in products) { var codeQuantity = product.Split('|'); if (codeQuantity.Length != 2) { continue; } uint quantity = 0; uint.TryParse(codeQuantity[1], out quantity); if (quantity < 1) { continue; } var productCode = codeQuantity[0]; if (!args.CartItems.ContainsKey(productCode)) { args.CartItems.Add(productCode, quantity); } else if (args.CartItems[productCode] < quantity) { args.CartItems[productCode] = quantity; } } } }
public void Process(RestoreCartArgs args) { CartPersistenceContext.PersistenceInitialized = true; }
public static void Run(RestoreCartArgs args) { CorePipeline.Run(Pipeline, args); }