/// <summary> /// Reloads the form data. /// </summary> protected void ReloadData() { rptCart.DataSource = ShoppingCart.ContentTable; // Hide coupon placeholder when no coupons are defined // *** plcCoupon.Visible = AreDiscountCouponsAvailableOnSite(); // Bind data rptCart.DataBind(); ReloadBillingAdresses(); ReloadShippingAdresses(); if (!DataHelper.DataSourceIsEmpty(ShoppingCart.ContentTable)) { // Display total price DisplayTotalPrice(); // Display/hide discount column //gridData.Columns[9].Visible = ShoppingCart.IsDiscountApplied; } else { // Hide some items // *** HideCartContentWhenEmpty(); } if (!ShippingOptionInfoProvider.IsShippingNeeded(ShoppingCart)) { // *** plcShippingPrice.Visible = false; } }
/// <summary> /// Reloads the form data. /// </summary> protected void ReloadData() { //gridData.DataSource = ShoppingCartInfoObj.ShoppingCartContentTable; gridData.DataSource = ShoppingCartInfoObj.ContentTable; // Hide coupon placeholder when no coupons are defined plcCoupon.Visible = AreDiscountCouponsAvailableOnSite(); // Bind data gridData.DataBind(); if (!DataHelper.DataSourceIsEmpty(ShoppingCartInfoObj.ContentTable)) { // Display total price DisplayTotalPrice(); // Display/hide discount column gridData.Columns[8].Visible = this.ShoppingCartInfoObj.IsDiscountApplied; } else { // Hide some items HideCartContentWhenEmpty(); } if (!ShippingOptionInfoProvider.IsShippingNeeded(this.ShoppingCartInfoObj)) { this.plcShippingPrice.Visible = false; } }
/// <summary> /// Reloads the form data. /// </summary> protected void ReloadData() { //gridData.DataSource = ShoppingCartInfoObj.ShoppingCartContentTable; gridData.DataSource = ShoppingCart.ContentTable; // Bind data gridData.DataBind(); if (!DataHelper.DataSourceIsEmpty(ShoppingCart.ContentTable)) { // Display total price DisplayTotalPrice(); // Display/hide discount column gridData.Columns[9].Visible = ShoppingCart.IsItemDiscountApplied; } else { // Hide some items HideCartContent(); } // Show order related discounts plcMultiBuyDiscountArea.Visible = ShoppingCart.OrderRelatedDiscountSummaryItems.Count > 0; ShoppingCart.OrderRelatedDiscountSummaryItems.ForEach(d => { plcOrderRelatedDiscountNames.Controls.Add(new LocalizedLabel { Text = HTMLHelper.HTMLEncode(ResHelper.LocalizeString(d.Name)) + ":", EnableViewState = false }); plcOrderRelatedDiscountNames.Controls.Add(new Literal { Text = "<br />", EnableViewState = false }); plcOrderRelatedDiscountValues.Controls.Add(new Label { Text = "- " + CurrencyInfoProvider.GetFormattedPrice(d.Value, ShoppingCart.Currency), EnableViewState = false }); plcOrderRelatedDiscountValues.Controls.Add(new Literal { Text = "<br />", EnableViewState = false }); }); //lblMultiBuyDiscountName.Text if (!ShippingOptionInfoProvider.IsShippingNeeded(ShoppingCart)) { plcShippingPrice.Visible = false; } }
public override bool ProcessStep() { string siteName = SiteContext.CurrentSiteName; if (IsExistingAccount()) { // Sign in customer with existing account // Authenticate user //UserInfo ui = UserInfoProvider.GetUserInfo(txtLogin.Text); UserInfo ui = AuthenticationHelper.AuthenticateUser(txtLogin.Text.Trim(), txtMotDePasse.Text, SiteContext.CurrentSiteName); if (ui == null) { // ShowError(ResHelper.GetString("ShoppingCartCheckRegistration.LoginFailed")); return(false); } // Set current user MembershipContext.AuthenticatedUser = new CurrentUserInfo(ui, true); UserInfoProvider.SetPreferredCultures(ui); // Sign in FormsAuthentication.SetAuthCookie(ui.UserName, false); // Registered user has already started shopping as anonymous user -> Drop his stored shopping cart ShoppingCartInfoProvider.DeleteShoppingCartInfo(ui.UserID, siteName); // Assign current user to the current shopping cart ShoppingCart.User = ui; // Save changes to database // Already done in the end of this method if (!this.ShoppingCartControl.IsInternalOrder) { ShoppingCartInfoProvider.SetShoppingCartInfo(this.ShoppingCartInfObj); } //Create a customer for the user if do not yet exist CustomerInfo ci = CustomerInfoProvider.GetCustomerInfoByUserID(this.ShoppingCartControl.UserInfo.UserID); if (ci == null) { ci = new CustomerInfo(); ci.CustomerUserID = this.ShoppingCartControl.UserInfo.UserID; ci.CustomerEnabled = true; } // Old email address //string oldEmail = ci.CustomerEmail.ToLower(); ; ci.CustomerFirstName = ui.FirstName; ci.CustomerLastName = ui.LastName; ci.CustomerEmail = ui.Email; ci.CustomerCompany = ""; ci.CustomerOrganizationID = ""; ci.CustomerTaxRegistrationID = ""; // Update customer data CustomerInfoProvider.SetCustomerInfo(ci); // Set the shopping cart customer ID this.ShoppingCart.ShoppingCartCustomerID = ci.CustomerID; } else if (IsNewAccount()) { txtEmail2.Text = txtEmail2.Text.Trim(); pnlCompanyAccount1.Visible = chkCorporateBody.Checked; // Check if user exists UserInfo ui = UserInfoProvider.GetUserInfo(txtEmail2.Text); if (ui != null) { lblError.Visible = true; lblError.Text = GetString("ShoppingCartUserRegistration.ErrorUserExists"); return(false); } // Check all sites where user will be assigned string checkSites = (String.IsNullOrEmpty(ShoppingCartControl.AssignToSites)) ? SiteContext.CurrentSiteName : ShoppingCartControl.AssignToSites; if (!UserInfoProvider.IsEmailUnique(txtEmail2.Text.Trim(), checkSites, 0)) { lblError.Visible = true; lblError.Text = GetString("UserInfo.EmailAlreadyExist"); return(false); } // Create new customer and user account and sign in // User ui = new UserInfo(); ui.UserName = txtEmailRegistration.Text.Trim(); ui.Email = txtEmailRegistration.Text.Trim(); ui.FirstName = txtFirstName.Text.Trim(); ui.FullName = UserInfoProvider.GetFullName(txtFirstName.Text.Trim(), String.Empty, txtLastName.Text.Trim()); ui.LastName = txtLastName.Text.Trim(); ui.Enabled = true; ui.UserIsGlobalAdministrator = false; ui.UserURLReferrer = MembershipContext.AuthenticatedUser.URLReferrer; ui.UserCampaign = AnalyticsHelper.Campaign; ui.UserSettings.UserRegistrationInfo.IPAddress = RequestContext.UserHostAddress; ui.UserSettings.UserRegistrationInfo.Agent = HttpContext.Current.Request.UserAgent; try { UserInfoProvider.SetPassword(ui, txtMotDePasseRegistration.Text); string[] siteList; // If AssignToSites field set if (!String.IsNullOrEmpty(ShoppingCartControl.AssignToSites)) { siteList = ShoppingCartControl.AssignToSites.Split(';'); } else // If not set user current site { siteList = new string[] { siteName }; } foreach (string site in siteList) { UserInfoProvider.AddUserToSite(ui.UserName, site); // Add user to roles if (ShoppingCartControl.AssignToRoles != "") { AssignUserToRoles(ui.UserName, ShoppingCartControl.AssignToRoles, site); } } // Log registered user AnalyticsHelper.LogRegisteredUser(siteName, ui); Activity activity = new ActivityRegistration(ui, DocumentContext.CurrentDocument, AnalyticsContext.ActivityEnvironmentVariables); if (activity.Data != null) { activity.Data.ContactID = ModuleCommands.OnlineMarketingGetUserLoginContactID(ui); activity.Log(); } } catch (Exception ex) { lblError.Visible = true; lblError.Text = ex.Message; return(false); } // Customer CustomerInfo ci = new CustomerInfo(); ci.CustomerFirstName = txtFirstName.Text.Trim(); ci.CustomerLastName = txtLastName.Text.Trim(); ci.CustomerEmail = txtEmailRegistration.Text.Trim(); ci.CustomerCompany = ""; ci.CustomerOrganizationID = ""; ci.CustomerTaxRegistrationID = ""; if (chkCorporateBody.Checked) { ci.CustomerCompany = txtCompany1.Text.Trim(); if (mShowOrganizationIDField) { ci.CustomerOrganizationID = txtOrganizationID.Text.Trim(); } if (mShowTaxRegistrationIDField) { ci.CustomerTaxRegistrationID = txtTaxRegistrationID.Text.Trim(); } } ci.CustomerUserID = ui.UserID; ci.CustomerSiteID = 0; ci.CustomerEnabled = true; ci.CustomerCreated = DateTime.Now; CustomerInfoProvider.SetCustomerInfo(ci); // Track successful registration conversion string name = ShoppingCartControl.RegistrationTrackConversionName; ECommerceHelper.TrackRegistrationConversion(ShoppingCart.SiteName, name); // Log "customer registration" activity and update profile var activityCustomerRegistration = new ActivityCustomerRegistration(ci, MembershipContext.AuthenticatedUser, AnalyticsContext.ActivityEnvironmentVariables); if (activityCustomerRegistration.Data != null) { if (ContactID <= 0) { activityCustomerRegistration.Data.ContactID = ModuleCommands.OnlineMarketingGetUserLoginContactID(ui); } activityCustomerRegistration.Log(); } // Sign in if (ui.UserEnabled) { CMSContext.AuthenticateUser(ui.UserName, false); ShoppingCart.User = ui; ContactID = ModuleCommands.OnlineMarketingGetUserLoginContactID(ui); Activity activity = new ActivityUserLogin(ContactID, ui, DocumentContext.CurrentDocument, AnalyticsContext.ActivityEnvironmentVariables); activity.Log(); } ShoppingCart.ShoppingCartCustomerID = ci.CustomerID; // Send new registration notification email if (ShoppingCartControl.SendNewRegistrationNotificationToAddress != "") { SendRegistrationNotification(ui); } /**aadrresse*/ // Process billing address //------------------------ int CountryID = ValidationHelper.GetInteger(ddlShippingCountry.SelectedValue, 0); AddressInfo ai = null; bool newAddress = true; ai = new AddressInfo(); string mCustomerName = ci.CustomerFirstName + " " + ci.CustomerLastName; // newAddress.AddressName = mCustomerName + " , " + txtAdresse.Text + " - " + txtCodePostale.Text + " " + txtVille.Text; ai.AddressPersonalName = mCustomerName + " , " + txtAdresse.Text + " - " + txtCodePostale.Text + " " + txtVille.Text; ai.AddressLine1 = txtAdresse.Text.Trim(); ai.AddressLine2 = txtAdresse.Text.Trim(); ai.AddressCity = txtVille.Text.Trim(); ai.AddressZip = txtCodePostale.Text.Trim(); ai.AddressCountryID = CountryID; if (newAddress) { ai.AddressIsBilling = true; ai.AddressIsShipping = !chkShippingAddr.Checked; ai.AddressEnabled = true; } ai.AddressCustomerID = ci.CustomerID; ai.AddressName = AddressInfoProvider.GetAddressName(ai); // Save address and set it's ID to ShoppingCartInfoObj AddressInfoProvider.SetAddressInfo(ai); // Update current contact's address ModuleCommands.OnlineMarketingMapAddress(ai, ContactID); ShoppingCart.ShoppingCartBillingAddressID = ai.AddressID; // If shopping cart does not need shipping if (!ShippingOptionInfoProvider.IsShippingNeeded(ShoppingCart)) { ShoppingCart.ShoppingCartShippingAddressID = 0; } // If shipping address is different from billing address else if (chkShippingAddr.Checked) { //// Check country presence //if (CountrySelector2.CountryID <= 0) //{ // lblError.Visible = true; // lblError.Text = GetString("countryselector.selectedcountryerr"); // return false; //} //if (!CountrySelector2.StateSelectionIsValid) //{ // lblError.Visible = true; // lblError.Text = GetString("countryselector.selectedstateerr"); // return false; //} //newAddress = false; //// Process shipping address ////------------------------- //ai = AddressInfoProvider.GetAddressInfo(Convert.ToInt32(drpShippingAddr.SelectedValue)); //if (ai == null) //{ // ai = new AddressInfo(); // newAddress = true; //} ai.AddressPersonalName = txtadresseshipping.Text.Trim(); ai.AddressLine1 = txtadresseshipping.Text.Trim(); ai.AddressLine2 = txtadresseshipping.Text.Trim(); ai.AddressCity = txtvilleshipping.Text.Trim(); ai.AddressZip = txtcpshipping.Text.Trim(); ai.AddressCountryID = CountryID; if (newAddress) { ai.AddressIsShipping = true; ai.AddressEnabled = true; ai.AddressIsBilling = false; ai.AddressIsCompany = false; ai.AddressEnabled = true; } ai.AddressCustomerID = ci.CustomerID; ai.AddressName = AddressInfoProvider.GetAddressName(ai); // Save address and set it's ID to ShoppingCartInfoObj AddressInfoProvider.SetAddressInfo(ai); ShoppingCart.ShoppingCartShippingAddressID = ai.AddressID; } // Shipping address is the same as billing address else { ShoppingCart.ShoppingCartShippingAddressID = ShoppingCart.ShoppingCartBillingAddressID; } /**finadrress*/ this.ShoppingCartControl.ButtonNextClickAction(); } try { if (!this.ShoppingCartControl.IsInternalOrder) { ShoppingCartInfoProvider.SetShoppingCartInfo(this.ShoppingCart); } return(true); } catch { return(false); } }
/// <summary> /// Process valid values of this step. /// </summary> public override bool ProcessStep() { // AddressInfo ai = null; bool newAddress = false; if (mCustomerId > 0) { // Clean the viewstate RemoveBillingTempValues(); RemoveShippingTempValues(); RemoveCompanyTempValues(); // Process billing address /*if (ai == null) * { * ai = new AddressInfo(); * newAddress = true; * } * * if (newAddress) * { * ai.AddressIsBilling = true; * ai.AddressEnabled = true; * } * ai.AddressCustomerID = mCustomerId; * ai.AddressName = AddressInfoProvider.GetAddressName(ai); * * // Save address and set it's ID to ShoppingCartInfoObj * AddressInfoProvider.SetAddressInfo(ai);*/ // Update current contact's address ModuleCommands.OnlineMarketingMapAddress(AddressInfoProvider.GetAddressInfo(ShoppingCart.ShoppingCartBillingAddressID), ContactID); // If shopping cart does not need shipping if (!ShippingOptionInfoProvider.IsShippingNeeded(ShoppingCart)) { ShoppingCart.ShoppingCartShippingAddressID = 0; } // If shipping address is different from billing address /* * else if (chkShippingAddr.Checked) * { * * newAddress = false; * // Process shipping address * //------------------------- * if (ai == null) * { * ai = new AddressInfo(); * newAddress = true; * } * * if (newAddress) * { * ai.AddressIsShipping = true; * ai.AddressEnabled = true; * ai.AddressIsBilling = false; * ai.AddressIsCompany = false; * ai.AddressEnabled = true; * } * ai.AddressCustomerID = mCustomerId; * ai.AddressName = AddressInfoProvider.GetAddressName(ai); * * // Save address and set it's ID to ShoppingCartInfoObj * AddressInfoProvider.SetAddressInfo(ai); * ShoppingCart.ShoppingCartShippingAddressID = ai.AddressID; * } * // Shipping address is the same as billing address * else * { * ShoppingCart.ShoppingCartShippingAddressID = ShoppingCart.ShoppingCartBillingAddressID; * }*/ try { // Update changes in database only when on the live site if (!ShoppingCartControl.IsInternalOrder) { ShoppingCartInfoProvider.SetShoppingCartInfo(ShoppingCart); } return(true); } catch (Exception ex) { // Show error message lblError.Visible = true; lblError.Text = ex.Message; return(false); } } else { lblError.Visible = true; lblError.Text = GetString("Ecommerce.NoCustomerSelected"); return(false); } }
/// <summary> /// Reloads the form data. /// </summary> /// <summary> /// Page load. /// </summary> protected void Page_Load(object sender, EventArgs e) { // *** SERVRANX START*** ShowPaymentList(); if (!rdbVisa.Checked && !rdbMaestro.Checked && !rdbMastercard.Checked) { rdbVisa.Checked = true; rdoBtn_CheckedChanged(null, null); } ddlPaymentOption.SelectedValue = SessionHelper.GetValue("PaymentID").ToString(); ddlPaymentOption_SelectedIndexChanged(null, null); string where = string.Format("AddressCustomerID={0} AND AddressIsBilling=1", ECommerceContext.CurrentCustomer.CustomerID.ToString()); string orderby = "AddressID"; DataSet ds = AddressInfoProvider.GetAddresses(where, orderby); if (!DataHelper.DataSourceIsEmpty(ds)) { AddressInfo ai = new AddressInfo(ds.Tables[0].Rows[0]); lblBillingAddressFullName.Text = ai.AddressPersonalName; lblBillingAddressStreet.Text = string.IsNullOrEmpty(ai.AddressLine2) ? ai.AddressLine1 : string.Format("{0}, {1}", ai.AddressLine1, ai.AddressLine2); lblBillingAddressZipCode.Text = ai.AddressZip; lblBillingAddressCityCountry.Text = string.Format("{0}, {1}", ai.AddressCity, CountryInfoProvider.GetCountryInfo(ai.AddressCountryID).CountryDisplayName); ShoppingCart.ShoppingCartBillingAddressID = ai.AddressID; } where = string.Format("AddressCustomerID={0} AND AddressIsShipping=1", ECommerceContext.CurrentCustomer.CustomerID.ToString()); ds = AddressInfoProvider.GetAddresses(where, orderby); if (!DataHelper.DataSourceIsEmpty(ds)) { AddressInfo ai = new AddressInfo(ds.Tables[0].Rows[0]); lblShippingAddressFullName.Text = ai.AddressPersonalName; lblShippingAddressStreet.Text = string.IsNullOrEmpty(ai.AddressLine2) ? ai.AddressLine1 : string.Format("{0}, {1}", ai.AddressLine1, ai.AddressLine2); lblShippingAddressZipCode.Text = ai.AddressZip; lblShippingAddressCityCountry.Text = string.Format("{0}, {1}", ai.AddressCity, CountryInfoProvider.GetCountryInfo(ai.AddressCountryID).CountryDisplayName); ShoppingCart.ShoppingCartShippingAddressID = ai.AddressID; } else { // NO SHIPPING ADDRESS DEFINED- PICK FIRST BILLING ADDRESS AddressInfo ai_shipping = AddressInfoProvider.GetAddressInfo(ShoppingCart.ShoppingCartBillingAddressID); ai_shipping.AddressIsShipping = true; AddressInfoProvider.SetAddressInfo(ai_shipping); where = string.Format("AddressCustomerID={0} AND AddressIsShipping=1", ECommerceContext.CurrentCustomer.CustomerID.ToString()); ds = AddressInfoProvider.GetAddresses(where, orderby); if (!DataHelper.DataSourceIsEmpty(ds)) { AddressInfo ai = new AddressInfo(ds.Tables[0].Rows[0]); lblShippingAddressFullName.Text = ai.AddressPersonalName; lblShippingAddressStreet.Text = string.IsNullOrEmpty(ai.AddressLine2) ? ai.AddressLine1 : string.Format("{0}, {1}", ai.AddressLine1, ai.AddressLine2); lblShippingAddressZipCode.Text = ai.AddressZip; lblShippingAddressCityCountry.Text = string.Format("{0}, {1}", ai.AddressCity, CountryInfoProvider.GetCountryInfo(ai.AddressCountryID).CountryDisplayName); ShoppingCart.ShoppingCartShippingAddressID = ai.AddressID; } } ReloadData(); // *** SERVRANX END*** mCurrentSite = SiteContext.CurrentSite; //lblBillingTitle.Text = GetString("ShoppingCart.BillingAddress"); //lblShippingTitle.Text = GetString("ShoppingCart.ShippingAddress"); //lblCompanyAddressTitle.Text = GetString("ShoppingCart.CompanyAddress"); // Initialize labels. // LabelInitialize(); //this.TitleText = GetString("Order_new.ShoppingCartOrderAddresses.Title"); // Get customer ID from ShoppingCartInfoObj mCustomerId = ShoppingCart.ShoppingCartCustomerID; // Get customer info. CustomerInfo ci = CustomerInfoProvider.GetCustomerInfo(mCustomerId); if (ci != null) { // Display customer addresses if customer is not anonymous if (ci.CustomerID > 0) { if (!ShoppingCartControl.IsCurrentStepPostBack) { // Initialize customer billing and shipping addresses InitializeAddresses(); } } } // If shopping cart does not need shipping if (!ShippingOptionInfoProvider.IsShippingNeeded(ShoppingCart)) { // Hide title lblBillingTitle.Visible = false; // Change current checkout process step caption ShoppingCartControl.CheckoutProcessSteps[ShoppingCartControl.CurrentStepIndex].Caption = GetString("order_new.shoppingcartorderaddresses.titlenoshipping"); } }
private bool ValidateShoppingCart(ShoppingCartInfo shoppingCart) { bool valid = true; // Check currency if (shoppingCart.Currency == null) { valid = false; LogError("Missing currency", EVENT_CODE_VALIDATION); } // Check shopping cart items. // The following conditions must be met to pass the check: // 1)All shopping cart items are enabled 2)Max units in one order are not exceeded // 3)There is enough units in the inventory 4) Customer is registered, if there is a membership type product in the cart // 5)Product validity is valid, if there is a membership or e-product type product in the cart ShoppingCartCheckResult result = ShoppingCartInfoProvider.CheckShoppingCart(shoppingCart); if (result.CheckFailed || shoppingCart.IsEmpty) { valid = false; LogError("Invalid items", EVENT_CODE_VALIDATION); } // Check customer if (shoppingCart.Customer == null) { valid = false; LogError("Missing customer", EVENT_CODE_VALIDATION); } // Check BillingAddress if (shoppingCart.ShoppingCartBillingAddress == null) { valid = false; LogError("Missing billing address", EVENT_CODE_VALIDATION); } // Check PaymentOption if (shoppingCart.PaymentOption == null) { valid = false; LogError("Missing payment", EVENT_CODE_VALIDATION); } // Check whether payment option is valid for user. string message; if (!CheckPaymentOptionIsValidForUser(shoppingCart, out message)) { LogError(message, EVENT_CODE_VALIDATION); valid = false; } // Check payment is valid for cart shipping if (!CheckPaymentIsAllowedForShipping(shoppingCart, shoppingCart.ShoppingCartPaymentOptionID)) { LogError("Invalid payment option for selected shipping", EVENT_CODE_VALIDATION); valid = false; } // If there is at least one product that needs shipping if (ShippingOptionInfoProvider.IsShippingNeeded(shoppingCart)) { // Check shipping option if (shoppingCart.ShippingOption == null) { valid = false; LogError("Missing shipping option", EVENT_CODE_VALIDATION); } } return(valid); }
protected void btnOk_Click(object sender, EventArgs e) { // check 'EcommerceModify' permission if (!ECommerceContext.IsUserAuthorizedForPermission("ModifyOrders")) { RedirectToAccessDenied("CMS.Ecommerce", "EcommerceModify OR ModifyOrders"); } // Get order OrderInfo oi = OrderInfoProvider.GetOrderInfo(orderId); if (oi != null) { // Get order site SiteInfo si = SiteInfoProvider.GetSiteInfo(oi.OrderSiteID); // If shipping address is required if (((this.ShoppingCartInfoObj != null) && (ShippingOptionInfoProvider.IsShippingNeeded(this.ShoppingCartInfoObj))) || ((si != null) && (ECommerceSettings.ApplyTaxesBasedOn(si.SiteName) == ApplyTaxBasedOnEnum.ShippingAddress))) { // If shipping address is not set if (this.addressElem.AddressID <= 0) { lblError.Visible = true; lblError.Text = GetString("Order_Edit_Shipping.NoAddress"); return; } } try { // Load the shopping cart to process the data ShoppingCartInfo sci = ShoppingCartInfoProvider.GetShoppingCartInfoFromOrder(orderId); if (sci != null) { // Set order new properties sci.ShoppingCartShippingOptionID = drpShippingOption.ShippingID; sci.ShoppingCartShippingAddressID = this.addressElem.AddressID; // Evaulate order data ShoppingCartInfoProvider.EvaluateShoppingCart(sci); // Update order data ShoppingCartInfoProvider.SetOrder(sci, false); } // Update tracking number oi.OrderTrackingNumber = txtTrackingNumber.Text.Trim(); OrderInfoProvider.SetOrderInfo(oi); lblInfo.Visible = true; lblInfo.Text = GetString("General.ChangesSaved"); } catch (Exception ex) { lblError.Visible = true; lblError.Text = ex.Message; } } }
protected void btnOk_Click(object sender, EventArgs e) { // check 'EcommerceModify' permission if (!ECommerceContext.IsUserAuthorizedForPermission("ModifyOrders")) { RedirectToAccessDenied("CMS.Ecommerce", "EcommerceModify OR ModifyOrders"); } // Get order OrderInfo oi = OrderInfoProvider.GetOrderInfo(orderId); if (oi != null) { // Are taxes based on shipping address? bool taxesBasedOnShipping = false; SiteInfo si = SiteInfoProvider.GetSiteInfo(oi.OrderSiteID); if (si != null) { taxesBasedOnShipping = (ECommerceSettings.ApplyTaxesBasedOn(si.SiteName) == ApplyTaxBasedOnEnum.ShippingAddress); } // Is shipping needed? bool isShippingNeeded = ((ShoppingCartInfoObj != null) && (ShippingOptionInfoProvider.IsShippingNeeded(ShoppingCartInfoObj))); // If shipping address is required if (isShippingNeeded || taxesBasedOnShipping) { // If shipping address is not set if (addressElem.AddressID <= 0) { // Show error message ShowError(GetString("Order_Edit_Shipping.NoAddress")); return; } } try { // Load the shopping cart to process the data ShoppingCartInfo sci = ShoppingCartInfoProvider.GetShoppingCartInfoFromOrder(orderId); if (sci != null) { // Set order new properties sci.ShoppingCartShippingOptionID = drpShippingOption.ShippingID; sci.ShoppingCartShippingAddressID = addressElem.AddressID; // Evaluate order data ShoppingCartInfoProvider.EvaluateShoppingCart(sci); // Update order data ShoppingCartInfoProvider.SetOrder(sci, false); } // Update tracking number oi.OrderTrackingNumber = txtTrackingNumber.Text.Trim(); OrderInfoProvider.SetOrderInfo(oi); // Show message ShowChangesSaved(); // Update shipping charge in selector if (taxesBasedOnShipping) { drpShippingOption.ShoppingCart = sci; drpShippingOption.Reload(false); } } catch (Exception ex) { // Show error message ShowError(ex.Message); } } }