public void Process(PersistCartArgs args)
        {
            var user = args.CustomerManager.CurrentUser;

            if (user == null || string.IsNullOrEmpty(user.NickName) || Sitecore.Context.Domain.IsAnonymousUser(user.NickName))
            {
                return;
            }

            //CustomerInfo does not seem to be able to reset to an empty/null value, so we need to use an empty indicator

            var coupon = EmptyCart;

            if (!string.IsNullOrEmpty(args.CouponCode))
            {
                coupon = args.CouponCode;
            }

            var cartItems = EmptyCart;

            if (args.CartItems != null && args.CartItems.Any())
            {
                cartItems = string.Join(",", args.CartItems.Select(x => string.Format("{0}|{1}", x.Key, x.Value)));
            }

            user.CustomProperties[CouponCodeKey] = coupon;
            user.CustomProperties[CartItemsKey]  = cartItems;
            args.CustomerManager.UpdateCustomerProfile(user);
        }
 public void Process(PersistCartArgs args)
 {
     if (!CartPersistenceContext.CartUpdated)
     {
         args.AbortPipeline();
         return;
     }
 }
Esempio n. 3
0
        public void Process(PersistCartArgs args)
        {
            var cart = args.ShoppingCart;

            args.CartItems = new Dictionary <string, uint>();
            foreach (var line in cart.ShoppingCartLines)
            {
                args.CartItems.Add(line.Product.Code, line.Quantity);
            }
            args.CouponCode = string.Join("|", cart.CouponCodes);
        }
        public void Process(PersistCartArgs args)
        {
            var cookie = new ShoppingCartCookie();

            cookie.CartItems.Clear();
            foreach (var item in args.CartItems)
            {
                cookie.CartItems.Add(item.Key, item.Value);
            }
            cookie.CouponCode = args.CouponCode;
            cookie.Save();
        }
Esempio n. 5
0
 public void Process(PersistCartArgs args)
 {
     Assert.ArgumentNotNull(args.ShoppingCart, "ShoppingCart");
     Assert.ArgumentNotNull(args.CustomerManager, "CustomerManager");
 }
 public static void Run(PersistCartArgs args)
 {
     CorePipeline.Run(Pipeline, args);
 }