protected ShoppingCartInfo GetNewCart() { ShoppingCartInfo newCart = ShoppingCartInfoProvider.CreateShoppingCartInfo(CMSContext.CurrentSite.SiteID); if (customerId > 0) { CustomerInfo ci = CustomerInfoProvider.GetCustomerInfo(customerId); if (ci != null) { UserInfo ui = null; if (ci.CustomerUserID > 0) { ui = UserInfoProvider.GetUserInfo(ci.CustomerUserID); newCart.UserInfoObj = ui; } //if (ui == null) //{ // ui = CMSContext.GlobalPublicUser; //} //newCart.UserInfoObj = ui; newCart.ShoppingCartCustomerID = customerId; } } return(newCart); }
/// <summary> /// Page load. /// </summary> protected void Page_Load(object sender, EventArgs e) { var currentSite = SiteContext.CurrentSite; // If shopping cart is created -> create empty one if ((ShoppingCartInfoObj == null) && (currentSite != null)) { ShoppingCartInfoObj = ShoppingCartInfoProvider.CreateShoppingCartInfo(currentSite.SiteID); // Set users preferred options var currentUser = MembershipContext.AuthenticatedUser; if ((currentUser != null) && (!currentUser.IsPublic())) { ShoppingCartInfoObj.ShoppingCartCurrencyID = currentUser.GetUserPreferredCurrencyID(currentSite.SiteName); } } // Display / hide checkout process images plcCheckoutProcess.Visible = DisplayStepImages; // Load current step data LoadCurrentStep(); if (CurrentStepIndex == 0) { ShoppingCartInfoObj.PrivateDataCleared = false; btnBack.Enabled = IsLiveSite; } // If shopping cart information exist if (ShoppingCartInfoObj != null) { // Get order information var order = OrderInfoProvider.GetOrderInfo(ShoppingCartInfoObj.OrderId); // If order is paid if ((order != null) && (order.OrderIsPaid)) { // Disable specific controls btnNext.Enabled = false; CurrentStepControl.Enabled = false; } } }
/// <summary> /// Page load. /// </summary> protected void Page_Load(object sender, EventArgs e) { lbldroit.Text = GetString("textedroit"); pnlStepButtons.Visible = !IsLiveSite; // If shopping cart is created -> create empty one if ((ShoppingCartInfoObj == null) && (SiteContext.CurrentSite != null)) { ShoppingCartInfoObj = ShoppingCartInfoProvider.CreateShoppingCartInfo(CMSContext.CurrentSiteID); // Set customer preffered options CustomerInfo currentCustomer = ECommerceContext.CurrentCustomer; if ((currentCustomer != null) && (currentCustomer.CustomerUser != null)) { ShoppingCartInfoObj.ShoppingCartCurrencyID = currentCustomer.CustomerUser.GetUserPreferredCurrencyID(SiteContext.CurrentSiteName); } } if (CurrentStepIndex == 0) { ShoppingCartInfoObj.PrivateDataCleared = false; } // Display / hide checkout process images plcCheckoutProcess.Visible = DisplayStepImages; // Load current step data LoadCurrentStep(); // If shopping cart information exist if (ShoppingCartInfoObj != null) { // Get order information OrderInfo oi = OrderInfoProvider.GetOrderInfo(ShoppingCartInfoObj.OrderId); // If order is paid if ((oi != null) && (oi.OrderIsPaid)) { // Disable specific controls btnNext.Enabled = false; CurrentStepControl.Enabled = false; } } }
protected ShoppingCartInfo GetNewCart() { ShoppingCartInfo newCart = ShoppingCartInfoProvider.CreateShoppingCartInfo(SiteContext.CurrentSite.SiteID); if (customerId > 0) { CustomerInfo ci = CustomerInfoProvider.GetCustomerInfo(customerId); if (ci != null) { if (ci.CustomerIsRegistered) { newCart.User = UserInfoProvider.GetUserInfo(ci.CustomerUserID); } newCart.ShoppingCartCustomerID = customerId; } } return(newCart); }
/// <summary> /// Creates a new shopping cart record and corresponding shopping cart items records in the database /// as a copy of given shopping cart info. /// Currency is set according to the currency of given cart. /// If a configuration of cart item is no longer available it is not cloned to new shopping cart. /// Correct user id for logged user is _not_ handled in this method, because it does not depend on /// abandoned cart's user id. It should be handled according to user's status (logged in/anonymous) /// in the browser where the cart is loaded: /// - anonymous cart or user's cart opened in the browser where user is logged in - new cart userId should be set to logged user's id /// - anonymous cart or user's cart opened in the browser where user is _not_ logged in - new cart userId should be empty (anonymous cart) /// </summary> /// <param name="originalCart">Original cart to clone.</param> /// <returns>Created shopping cart info.</returns> private ShoppingCartInfo CloneShoppingCartInfo(ShoppingCartInfo originalCart) { using (new CMSActionContext { UpdateTimeStamp = false }) { ShoppingCartInfo cartClone = ShoppingCartInfoProvider.CreateShoppingCartInfo(CurrentSite.SiteID); cartClone.ShoppingCartCurrencyID = originalCart.ShoppingCartCurrencyID; cartClone.ShoppingCartLastUpdate = originalCart.ShoppingCartLastUpdate; ShoppingCartInfoProvider.SetShoppingCartInfo(cartClone); ShoppingCartInfoProvider.CopyShoppingCartItems(originalCart, cartClone); // Set the shopping cart items into the database foreach (ShoppingCartItemInfo item in cartClone.CartItems) { ShoppingCartItemInfoProvider.SetShoppingCartItemInfo(item); } return(cartClone); } }