/// <summary> /// Adds to shopping cart. /// </summary> /// <param name="productCode">The product code.</param> /// <param name="quantity">The quantity.</param> public static void AddToShoppingCart(string productCode, string quantity) { Assert.ArgumentNotNullOrEmpty(productCode, "productCode"); Assert.ArgumentNotNullOrEmpty(quantity, "quantity"); IShoppingCartManager shoppingCartManager = Context.Entity.Resolve <IShoppingCartManager>(); uint q; if (string.IsNullOrEmpty(quantity) || !uint.TryParse(quantity, out q)) { shoppingCartManager.AddProduct(productCode, 1); } else { shoppingCartManager.AddProduct(productCode, q); } ShoppingCart shoppingCart = Context.Entity.GetInstance <ShoppingCart>(); ShoppingCartLine existingShoppingCartLine = shoppingCart.ShoppingCartLines.FirstOrDefault(p => p.Product.Code.Equals(productCode)); try { Tracker.StartTracking(); AnalyticsUtil.AddToShoppingCart(existingShoppingCartLine.Product.Code, existingShoppingCartLine.Product.Title, 1, existingShoppingCartLine.Totals.PriceExVat); } catch (Exception ex) { LogException(ex); } }