/// <summary> /// Sets up the control. /// </summary> public void SetupControl() { if (StopProcessing) { return; } // Do not use webpart settings if e-commerce setting AutomaticCustomerRegistration is true if (ECommerceSettings.AutomaticCustomerRegistration(SiteContext.CurrentSiteID)) { // Show error message only on Page and Design tabs if ((PortalContext.ViewMode == ViewModeEnum.Design) || (PortalContext.ViewMode == ViewModeEnum.Edit)) { pnlCheckBox.Visible = false; pnlError.Visible = true; lblError.Text = GetString("com.checkout.registeraftercheckouterror"); } else { IsVisible = false; } } else if (CurrentUser.IsPublic()) { // Show the control chkRegister.Text = GetStringValue("Text", ""); chkRegister.Checked = ValidationHelper.GetBoolean(GetValue("Checked"), false); // Use webpart settings, not e-commerce settings useWebpartSettings = true; } else { IsVisible = false; } }
/// <summary> /// Indicates if exchange rate from global main currency is needed. /// </summary> protected bool IsFromGlobalRateNeeded() { var siteId = ConfiguredSiteID; if ((siteId == 0) || (ECommerceSettings.UseGlobalCurrencies(siteId))) { return(false); } string globalMainCode = CurrencyInfoProvider.GetMainCurrencyCode(0); string siteMainCode = CurrencyInfoProvider.GetMainCurrencyCode(siteId); // Check whether main currencies are defined if (string.IsNullOrEmpty(siteMainCode) || string.IsNullOrEmpty(globalMainCode)) { return(false); } // Check whether global and site main currency are the same if (globalMainCode.EqualsCSafe(siteMainCode, true)) { return(false); } // Check if site has currency with same code as global main -> no need for global rate if (CurrencyInfoProvider.GetCurrenciesByCode(siteId).ContainsKey(globalMainCode)) { return(false); } return(ECommerceSettings.AllowGlobalDiscountCoupons(siteId) || ECommerceSettings.AllowGlobalProductOptions(siteId) || ECommerceSettings.AllowGlobalProducts(siteId) || ECommerceSettings.UseGlobalCredit(siteId) || ECommerceSettings.UseGlobalTaxClasses(siteId)); }
/// <summary> /// Creates where condition for product selector. /// </summary> protected string GetWhereCondition() { // Select nothing string where = "(1=0)"; if (mDiscountCouponInfoObj != null) { // Offer global products for global coupons or in case they are allowed if (mDiscountCouponInfoObj.IsGlobal || ECommerceSettings.AllowGlobalProducts(mDiscountCouponInfoObj.DiscountCouponSiteID)) { where = SqlHelper.AddWhereCondition(where, "SKUSiteID IS NULL", "OR"); } // Offer site product only for site coupons if (!mDiscountCouponInfoObj.IsGlobal) { where = SqlHelper.AddWhereCondition(where, "SKUSiteID = " + mDiscountCouponInfoObj.DiscountCouponSiteID, "OR"); } } where = SqlHelper.AddWhereCondition(where, "(SKUEnabled = 1) AND (SKUProductType != 'DONATION')"); // Include selected values if (!string.IsNullOrEmpty(mCurrentValues)) { string[] skuIds = mCurrentValues.Split(';'); int[] intSkuIds = ValidationHelper.GetIntegers(skuIds, 0); where = SqlHelper.AddWhereCondition(where, SqlHelper.GetWhereCondition("SKUID", intSkuIds.AsEnumerable()), "OR"); } // Select only products - not product options where = SqlHelper.AddWhereCondition(where, "SKUOptionCategoryID IS NULL"); return(where); }
/// <summary> /// Returns where condition for uniselector. Respects settings of global departments. /// </summary> public string GetWhereCondition() { string where = ""; // Add global items when editing global discount level or site allows global departments if ((editedSiteId == 0) || ECommerceSettings.AllowGlobalDepartments(SiteInfoProvider.GetSiteName(editedSiteId))) { where = SqlHelperClass.AddWhereCondition(where, "DepartmentSiteID IS NULL", "OR"); } // Add site specific items, when editing site specific discount level if (editedSiteId > 0) { where = SqlHelperClass.AddWhereCondition(where, "DepartmentSiteID = " + editedSiteId, "OR"); } // Add items which have to be on the list string valuesList = SqlHelperClass.GetSafeQueryString(mCurrentValues, false).Replace(';', ','); if (!string.IsNullOrEmpty(valuesList)) { where = SqlHelperClass.AddWhereCondition(where, " DepartmentID IN (" + valuesList + ")", "OR"); } return(where); }
protected override void OnInit(EventArgs e) { base.OnInit(e); SKUInfo sku = null; if (Node != null) { sku = SKUInfoProvider.GetSKUInfo(Node.NodeSKUID); } if ((sku != null) && (sku.SKUSiteID != CMSContext.CurrentSiteID) && ((sku.SKUSiteID != 0) || !ECommerceSettings.AllowGlobalProducts(CMSContext.CurrentSiteName))) { EditedObject = null; } productEditElem.ProductSaved += productEditElem_ProductSaved; }
/// <summary> /// Process this step. /// </summary> public override bool ProcessStep() { // Do not process step if order is paid if (OrderIsPaid) { return(false); } // Shopping cart units are already saved in database (on "Update" or on "btnAddProduct_Click" actions) bool isOK = false; if (ShoppingCart != null) { // Reload data ReloadData(); // Validate available items before "Check out" var cartValidator = new ShoppingCartValidator(ShoppingCart); cartValidator.Validate(); if (!cartValidator.IsValid) { lblError.Text = cartValidator.GetErrorMessages() .Select(e => HTMLHelper.HTMLEncode(e)) .Join("<br />"); } else if (ShoppingCartControl.CheckoutProcessType == CheckoutProcessEnum.CMSDeskOrderItems) { // Indicates whether order saving process is successful isOK = true; try { ShoppingCartInfoProvider.SetOrder(ShoppingCart); } catch (Exception ex) { // Log exception EventLogProvider.LogException("Shopping cart", "SAVEORDER", ex, ShoppingCart.ShoppingCartSiteID); isOK = false; } if (isOK) { lblInfo.Text = GetString("general.changessaved"); // Send order notification when editing existing order if (ShoppingCartControl.CheckoutProcessType == CheckoutProcessEnum.CMSDeskOrderItems) { if (chkSendEmail.Checked) { OrderInfoProvider.SendOrderNotificationToAdministrator(ShoppingCart); OrderInfoProvider.SendOrderNotificationToCustomer(ShoppingCart); } } // Send order notification emails when on the live site else if (ECommerceSettings.SendOrderNotification(SiteContext.CurrentSite.SiteName)) { OrderInfoProvider.SendOrderNotificationToAdministrator(ShoppingCart); OrderInfoProvider.SendOrderNotificationToCustomer(ShoppingCart); } } else { lblError.Text = GetString("ecommerce.orderpreview.errorordersave"); } } // Go to the next step else { // Save other options if (!ShoppingCartControl.IsInternalOrder) { ShoppingCartInfoProvider.SetShoppingCartInfo(ShoppingCart); } isOK = true; } } return(isOK); }
protected override void OnLoad(EventArgs e) { // Show message when reordering and not all reordered product were added to cart if (!RequestHelper.IsPostBack() && QueryHelper.GetBoolean("notallreordered", false)) { lblError.Text = GetString("com.notallreordered"); } if ((ShoppingCart != null) && IsLiveSite) { // Get order information OrderInfo oi = OrderInfoProvider.GetOrderInfo(ShoppingCart.OrderId); // If order is paid if ((oi != null) && (oi.OrderIsPaid)) { // Clean shopping cart if paid order cart is still in customers current cart on LS ShoppingCartControl.CleanUpShoppingCart(); } } if (ShoppingCart != null) { // Set currency selectors site ID selectCurrency.SiteID = ShoppingCart.ShoppingCartSiteID; } lnkNewItem.Text = GetString("ecommerce.shoppingcartcontent.additem"); btnUpdate.Text = GetString("ecommerce.shoppingcartcontent.btnupdate"); btnEmpty.Text = GetString("ecommerce.shoppingcartcontent.btnempty"); btnEmpty.OnClientClick = string.Format("return confirm({0});", ScriptHelper.GetString(GetString("ecommerce.shoppingcartcontent.emptyconfirm"))); // Add new product dialog string addProductUrl = ApplicationUrlHelper.GetElementDialogUrl(ModuleName.ECOMMERCE, "order.addorderitems", 0, GetCMSDeskShoppingCartSessionNameQuery()); lnkNewItem.OnClientClick = ScriptHelper.GetModalDialogScript(addProductUrl, "addproduct", 1000, 620); gridData.Columns[4].HeaderText = GetString("general.remove"); gridData.Columns[5].HeaderText = GetString("ecommerce.shoppingcartcontent.actions"); gridData.Columns[6].HeaderText = GetString("ecommerce.shoppingcartcontent.skuname"); gridData.Columns[7].HeaderText = GetString("ecommerce.shoppingcartcontent.skuunits"); gridData.Columns[8].HeaderText = GetString("ecommerce.shoppingcartcontent.unitprice"); gridData.Columns[9].HeaderText = GetString("ecommerce.shoppingcartcontent.itemdiscount"); gridData.Columns[10].HeaderText = GetString("ecommerce.shoppingcartcontent.subtotal"); gridData.RowDataBound += gridData_RowDataBound; // Hide "add product" action for live site order if (!ShoppingCartControl.IsInternalOrder) { pnlNewItem.Visible = false; ShoppingCartControl.ButtonBack.Text = GetString("ecommerce.cartcontent.buttonbacktext"); ShoppingCartControl.ButtonBack.ButtonStyle = ButtonStyle.Default; ShoppingCartControl.ButtonNext.Text = GetString("ecommerce.cartcontent.buttonnexttext"); if (!ShoppingCartControl.IsCurrentStepPostBack) { // Get shopping cart item parameters from URL ShoppingCartItemParameters itemParams = ShoppingCartItemParameters.GetShoppingCartItemParameters(); // Set item in the shopping cart AddProducts(itemParams); } } // Set sending order notification when editing existing order according to the site settings if (ShoppingCartControl.CheckoutProcessType == CheckoutProcessEnum.CMSDeskOrderItems) { if (!ShoppingCartControl.IsCurrentStepPostBack) { if (!string.IsNullOrEmpty(ShoppingCart.SiteName)) { chkSendEmail.Checked = ECommerceSettings.SendOrderNotification(ShoppingCart.SiteName); } } // Show send email checkbox chkSendEmail.Visible = true; chkSendEmail.Text = GetString("shoppingcartcontent.sendemail"); // Setup buttons ShoppingCartControl.ButtonBack.Visible = false; ShoppingCartControl.ButtonNext.Text = GetString("general.next"); if ((!ExistAnotherStepsExceptPayment) && (ShoppingCartControl.PaymentGatewayProvider == null)) { ShoppingCartControl.ButtonNext.Text = GetString("general.ok"); } } // Fill dropdownlist if (!ShoppingCartControl.IsCurrentStepPostBack) { if (!ShoppingCart.IsEmpty || ShoppingCartControl.IsInternalOrder) { selectCurrency.SelectedID = ShoppingCart.ShoppingCartCurrencyID; } ReloadData(); } // Ensure order currency in selector if ((ShoppingCartControl.CheckoutProcessType == CheckoutProcessEnum.CMSDeskOrderItems) && (ShoppingCart.Order != null)) { selectCurrency.AdditionalItems += ShoppingCart.Order.OrderCurrencyID + ";"; } HandlePostBack(); base.OnLoad(e); }
/// <summary> /// On page load. /// </summary> protected void Page_Load(object sender, EventArgs e) { ScriptHelper.RegisterClientScriptBlock(this, GetType(), "showHide", ScriptHelper.GetScript(@" /* Shows and hides tables with forms*/ function showHideForm(obj, rad) { var tblSignInStat = ''; var tblRegistrationStat = ''; var tblAnonymousStat = ''; if( obj != null && obj != '' && rad != null) { switch(obj) { case 'tblSignIn': tblSignInStat = ''; tblRegistrationStat = 'none'; tblAnonymousStat = 'none'; break; case 'tblRegistration': tblSignInStat = 'none'; tblRegistrationStat = ''; tblAnonymousStat = 'none'; break; case 'tblAnonymous': tblSignInStat = 'none'; tblRegistrationStat = 'none'; tblAnonymousStat = ''; break; } if(document.getElementById('tblSignIn') != null) document.getElementById('tblSignIn').style.display = tblSignInStat; if(document.getElementById('tblRegistration') != null) document.getElementById('tblRegistration').style.display = tblRegistrationStat; if(document.getElementById('tblAnonymous') != null) document.getElementById('tblAnonymous').style.display = tblAnonymousStat; if(document.getElementById(rad) != null) document.getElementById(rad).setAttribute('checked','true'); } } function showElem(id) { style = document.getElementById(id).style; style.display = (style.display == 'block')?'none':'block'; return false; } function showHideChk(id) { var elem = document.getElementById(id); if(elem.style.display == 'block') { elem.style.display = 'none'; } else { elem.style.display = 'block'; } }")); // Get settings for current site SiteInfo si = SiteContext.CurrentSite; if (si != null) { mRequireOrgTaxRegIDs = ECommerceSettings.RequireCompanyInfo(si.SiteName); mShowOrganizationIDField = ECommerceSettings.ShowOrganizationID(si.SiteName); mShowTaxRegistrationIDField = ECommerceSettings.ShowTaxRegistrationID(si.SiteName); } PreRender += CMSEcommerce_ShoppingCartCheckRegistration_PreRender; InitializeLabels(); LoadStep(false); // Initialize onclick events radSignIn.Attributes.Add("onclick", "showHideForm('tblSignIn','" + radSignIn.ClientID + "');"); radNewReg.Attributes.Add("onclick", "showHideForm('tblRegistration','" + radNewReg.ClientID + "');"); radAnonymous.Attributes.Add("onclick", "showHideForm('tblAnonymous','" + radAnonymous.ClientID + "');"); lnkPasswdRetrieval.Attributes.Add("onclick", "return showElem('" + pnlPasswdRetrieval.ClientID + "');"); }
/// <summary> /// Returns URL to the wish list. /// </summary> /// <param name="siteName">Site name</param> public static string WishlistURL(string siteName) { return(URLHelper.ResolveUrl(ECommerceSettings.WishListURL(siteName))); }
/// <summary> /// Initializes the control properties. /// </summary> protected void SetupControl() { if (StopProcessing) { // Do nothing } else { currentUser = MembershipContext.AuthenticatedUser; if (AuthenticationHelper.IsAuthenticated()) { // Control initialization lblTitle.Text = GetString("Ecommerce.Wishlist.Title"); btnContinue.Text = GetString("Ecommerce.Wishlist.btnContinue"); mSKUId = QueryHelper.GetInteger("productID", 0); currentSite = SiteContext.CurrentSite; // Set repeater transformation repeater.TransformationName = TransformationName; repeater.ItemSeparator = ItemSeparator; if ((currentUser != null) && (currentSite != null)) { if ((!RequestHelper.IsPostBack()) && (mSKUId > 0)) { int addSKUId = mSKUId; // Get added SKU info object from database SKUInfo skuObj = SKUInfoProvider.GetSKUInfo(addSKUId); if (skuObj != null) { // Can not add option as a product if (skuObj.SKUOptionCategoryID > 0) { addSKUId = 0; } else if (!skuObj.IsGlobal) { // Site specific product must belong to the current site if (skuObj.SKUSiteID != currentSite.SiteID) { addSKUId = 0; } } else { // Global products must be allowed when adding global product if (!ECommerceSettings.AllowGlobalProducts(currentSite.SiteName)) { addSKUId = 0; } } } if (addSKUId > 0) { // Add specified product to the user's wishlist WishlistItemInfoProvider.AddSKUToWishlist(currentUser.UserID, addSKUId, currentSite.SiteID); LogProductAddedToWLActivity(addSKUId, ResHelper.LocalizeString(skuObj.SKUName)); } } if (mSKUId > 0) { // Remove product parameter from URL to avoid adding it next time string newUrl = URLHelper.RemoveParameterFromUrl(RequestContext.CurrentURL, "productID"); URLHelper.Redirect(newUrl); } } } else { // Hide control if current user is not authenticated Visible = false; } } }
/// <summary> /// Checks exchange rates. /// </summary> private void CheckExchangeRates() { if (ExchangeRatesCheck) { int currentSiteID = 0; // Check if the site is using global exchage rates if (!ECommerceSettings.UseGlobalExchangeRates(CMSContext.CurrentSiteName)) { currentSiteID = CMSContext.CurrentSiteID; } // Retrieve last valid exchange table ExchangeTableInfo et = ExchangeTableInfoProvider.GetLastValidExchangeTableInfo(CMSContext.CurrentSiteID); if (et == null) { DisplayMessage("com.settingschecker.emptyexchangerate"); } else { DataSet ds = CurrencyInfoProvider.GetCurrencies(currentSiteID, true); if (!DataHelper.DataSourceIsEmpty(ds)) { // Prepare where condition StringBuilder sb = new StringBuilder(); foreach (DataRow item in ds.Tables[0].Rows) { sb.Append(item["CurrencyID"] + ","); } sb.Remove(sb.Length - 1, 1); // Get exchange rate from global currency, if some global checkboxes are checked if (mGlobalUsage) { double exchangerateFromGlobalCurrency = ExchangeTableInfoProvider.GetLastExchangeRateFromGlobalMainCurrency(CMSContext.CurrentSiteID); if (exchangerateFromGlobalCurrency <= 0) { DisplayMessage("com.settingschecker.emptyexchangerate"); return; } } // Get all exchange rates for selected table DataSet exchangeDs = ExchangeRateInfoProvider.GetExchangeRates("(ExchangeTableID = " + et.ExchangeTableID + ") AND (ExchangeRateToCurrencyID IN (" + sb.ToString() + "))", null); if (DataHelper.DataSourceIsEmpty(exchangeDs)) { // If there is only one currency in dataset, do not show error message if (ds.Tables[0].Rows.Count > 1) { DisplayMessage("com.settingschecker.emptyexchangerate"); return; } } // Check if count of currencies is same in exchangetable else if ((ds.Tables[0].Rows.Count != exchangeDs.Tables[0].Rows.Count)) { // If we are using global objects, there will be one more currency if (mGlobalUsage) { if (ds.Tables[0].Rows.Count != exchangeDs.Tables[0].Rows.Count + 1) { DisplayMessage("com.settingschecker.emptyexchangerate"); return; } } else { DisplayMessage("com.settingschecker.emptyexchangerate"); return; } } else { foreach (DataRow item in exchangeDs.Tables[0].Rows) { if (item["ExchangeRateValue"] == null) { DisplayMessage("com.settingschecker.emptyexchangerate"); break; } } } } } } }
/// <summary> /// Returns where condition based on webpart fields. /// </summary> private string GetWhereCondition() { string where = null; // Show products only from current site or global too, based on setting if (ECommerceSettings.AllowGlobalProducts(CMSContext.CurrentSiteName)) { where = "(SKUSiteID = " + CMSContext.CurrentSiteID + ") OR (SKUSiteID IS NULL)"; } else { where = "SKUSiteID = " + CMSContext.CurrentSiteID; } // Product type filter if (!string.IsNullOrEmpty(ProductType) && (ProductType != FILTER_ALL)) { if (ProductType == PRODUCT_TYPE_PRODUCTS) { where = SqlHelperClass.AddWhereCondition(where, "SKUOptionCategoryID IS NULL"); } else if (ProductType == PRODUCT_TYPE_PRODUCT_OPTIONS) { where = SqlHelperClass.AddWhereCondition(where, "SKUOptionCategoryID IS NOT NULL"); } } // Representing filter if (!string.IsNullOrEmpty(Representing) && (Representing != FILTER_ALL)) { SKUProductTypeEnum productTypeEnum = SKUInfoProvider.GetSKUProductTypeEnum(Representing); string productTypeString = SKUInfoProvider.GetSKUProductTypeString(productTypeEnum); where = SqlHelperClass.AddWhereCondition(where, "SKUProductType = N'" + productTypeString + "'"); } // Product number filter if (!string.IsNullOrEmpty(ProductNumber)) { string safeProductNumber = SqlHelperClass.GetSafeQueryString(ProductNumber, true); where = SqlHelperClass.AddWhereCondition(where, "SKUNumber LIKE N'%" + safeProductNumber + "%'"); } // Department filter DepartmentInfo di = DepartmentInfoProvider.GetDepartmentInfo(Department, CurrentSiteName); if (di != null) { where = SqlHelperClass.AddWhereCondition(where, "SKUDepartmentID = " + di.DepartmentID); } // Manufacturer filter ManufacturerInfo mi = ManufacturerInfoProvider.GetManufacturerInfo(Manufacturer, CurrentSiteName); if (mi != null) { where = SqlHelperClass.AddWhereCondition(where, "SKUManufacturerID = " + mi.ManufacturerID); } // Supplier filter SupplierInfo si = SupplierInfoProvider.GetSupplierInfo(Supplier, CurrentSiteName); if (si != null) { where = SqlHelperClass.AddWhereCondition(where, "SKUSupplierID = " + si.SupplierID); } // Needs shipping filter if (!string.IsNullOrEmpty(NeedsShipping) && (NeedsShipping != FILTER_ALL)) { if (NeedsShipping == NEEDS_SHIPPING_YES) { where = SqlHelperClass.AddWhereCondition(where, "SKUNeedsShipping = 1"); } else if (NeedsShipping == NEEDS_SHIPPING_NO) { where = SqlHelperClass.AddWhereCondition(where, "(SKUNeedsShipping = 0) OR (SKUNeedsShipping IS NULL)"); } } // Price from filter if (PriceFrom > 0) { where = SqlHelperClass.AddWhereCondition(where, "SKUPrice >= " + PriceFrom); } // Price to filter if (PriceTo > 0) { where = SqlHelperClass.AddWhereCondition(where, "SKUPrice <= " + PriceTo); } // Public status filter PublicStatusInfo psi = PublicStatusInfoProvider.GetPublicStatusInfo(PublicStatus, CurrentSiteName); if (psi != null) { where = SqlHelperClass.AddWhereCondition(where, "SKUPublicStatusID = " + psi.PublicStatusID); } // Internal status filter InternalStatusInfo isi = InternalStatusInfoProvider.GetInternalStatusInfo(InternalStatus, CurrentSiteName); if (isi != null) { where = SqlHelperClass.AddWhereCondition(where, "SKUInternalStatusID = " + isi.InternalStatusID); } // Allow for sale filter if (!string.IsNullOrEmpty(AllowForSale) && (AllowForSale != FILTER_ALL)) { if (AllowForSale == ALLOW_FOR_SALE_YES) { where = SqlHelperClass.AddWhereCondition(where, "SKUEnabled = 1"); } else if (AllowForSale == ALLOW_FOR_SALE_NO) { where = SqlHelperClass.AddWhereCondition(where, "(SKUEnabled = 0) OR (SKUEnabled IS NULL)"); } } // Available items filter if (!string.IsNullOrEmpty(AvailableItems)) { int value = ValidationHelper.GetInteger(AvailableItems, int.MaxValue); where = SqlHelperClass.AddWhereCondition(where, "SKUAvailableItems <= " + value); } // Needs to be reordered filter if (NeedsToBeReordered) { where = SqlHelperClass.AddWhereCondition(where, "((SKUReorderAt IS NULL) AND (SKUAvailableItems <= 0)) OR ((SKUReorderAt IS NOT NULL) AND (SKUAvailableItems <= SKUReorderAt))"); } return(where); }
/// <summary> /// Displays or hides columns based on VisibleColumns property. /// </summary> private void DisplayColumns() { string[] visibleColumns = VisibleColumns.Split('|'); // Hide all first foreach (var item in gridElem.NamedColumns.Values) { item.Visible = false; } // Show columns that should be visible foreach (var item in visibleColumns) { string key = null; switch (item) { case COLUMN_NUMBER: key = "Number"; break; case COLUMN_PRICE: key = "Price"; break; case COLUMN_DEPARTMENT: key = "Department"; break; case COLUMN_MANUFACTURER: key = "Manufacturer"; break; case COLUMN_SUPPLIER: key = "Supplier"; break; case COLUMN_PUBLIC_STATUS: key = "PublicStatus"; break; case COLUMN_INTERNAL_STATUS: key = "InternalStatus"; break; case COLUMN_REORDER_AT: key = "ReorderAt"; break; case COLUMN_AVAILABLE_ITEMS: key = "AvailableItems"; break; case COLUMN_ITEMS_TO_BE_REORDERED: key = "ItemsToBeReordered"; break; case COLUMN_ALLOW_FOR_SALE: key = "AllowForSale"; break; } // Show column if (key != null) { gridElem.NamedColumns[key].Visible = true; } } // Show option category column if not only product listed if (ProductType != PRODUCT_TYPE_PRODUCTS) { gridElem.NamedColumns["OptionCategory"].Visible = true; } // If global products are allowed, display column if (ECommerceSettings.AllowGlobalProducts(CMSContext.CurrentSiteName)) { gridElem.NamedColumns["Global"].Visible = true; } }
protected void Page_Load(object sender, EventArgs e) { currentSite = CMSContext.CurrentSite; this.lblTitle.Text = GetString("ShoppingCartPreview.Title"); if ((ShoppingCartInfoObj != null) && (ShoppingCartInfoObj.CountryID == 0) && (currentSite != null)) { string countryName = ECommerceSettings.DefaultCountryName(currentSite.SiteName); CountryInfo ci = CountryInfoProvider.GetCountryInfo(countryName); ShoppingCartInfoObj.CountryID = (ci != null) ? ci.CountryID : 0; } this.ShoppingCartControl.ButtonNext.Text = GetString("Ecommerce.OrderPreview.NextButtonText"); // addresses initialization pnlBillingAddress.GroupingText = GetString("Ecommerce.CartPreview.BillingAddressPanel"); pnlShippingAddress.GroupingText = GetString("Ecommerce.CartPreview.ShippingAddressPanel"); pnlCompanyAddress.GroupingText = GetString("Ecommerce.CartPreview.CompanyAddressPanel"); FillBillingAddressForm(ShoppingCartInfoObj.ShoppingCartBillingAddressID); FillShippingAddressForm(ShoppingCartInfoObj.ShoppingCartShippingAddressID); // Load company address if (ShoppingCartInfoObj.ShoppingCartCompanyAddressID > 0) { lblCompany.Text = OrderInfoProvider.GetAddress(ShoppingCartInfoObj.ShoppingCartCompanyAddressID); mAddressCount++; tdCompanyAddress.Visible = true; } else { tdCompanyAddress.Visible = false; } // Enable sending order notifications when creating order from CMSDesk if ((this.ShoppingCartControl.CheckoutProcessType == CheckoutProcessEnum.CMSDeskOrder) || this.ShoppingCartControl.CheckoutProcessType == CheckoutProcessEnum.CMSDeskCustomer) { chkSendEmail.Visible = true; chkSendEmail.Checked = ECommerceSettings.SendOrderNotification(currentSite.SiteName); chkSendEmail.Text = GetString("ShoppingCartPreview.SendNotification"); } // Show tax registration ID and organization ID InitializeIDs(); // shopping cart content table initialization gridData.Columns[4].HeaderText = GetString("Ecommerce.ShoppingCartContent.SKUName"); gridData.Columns[5].HeaderText = GetString("Ecommerce.ShoppingCartContent.SKUUnits"); gridData.Columns[6].HeaderText = GetString("Ecommerce.ShoppingCartContent.UnitPrice"); gridData.Columns[7].HeaderText = GetString("Ecommerce.ShoppingCartContent.UnitDiscount"); gridData.Columns[8].HeaderText = GetString("Ecommerce.ShoppingCartContent.Tax"); gridData.Columns[9].HeaderText = GetString("Ecommerce.ShoppingCartContent.Subtotal"); // Product tax summary table initialiazation gridTaxSummary.Columns[0].HeaderText = GetString("Ecommerce.CartContent.TaxDisplayName"); gridTaxSummary.Columns[1].HeaderText = GetString("Ecommerce.CartContent.TaxSummary"); // Shipping tax summary table initialiazation gridShippingTaxSummary.Columns[0].HeaderText = GetString("com.CartContent.ShippingTaxDisplayName"); gridShippingTaxSummary.Columns[1].HeaderText = GetString("Ecommerce.CartContent.TaxSummary"); ReloadData(); // order note initialization lblNote.Text = GetString("ecommerce.cartcontent.notelabel"); if (!this.ShoppingCartControl.IsCurrentStepPostBack) { // Try to select payment from ViewState first object viewStateValue = this.ShoppingCartControl.GetTempValue(ORDER_NOTE); if (viewStateValue != null) { this.txtNote.Text = Convert.ToString(viewStateValue); } else { this.txtNote.Text = ShoppingCartInfoObj.ShoppingCartNote; } } // Display/Hide column with applied discount gridData.Columns[7].Visible = this.ShoppingCartInfoObj.IsDiscountApplied; if (mAddressCount == 2) { tblAddressPreview.Attributes["class"] = "AddressPreviewWithTwoColumns"; } else if (mAddressCount == 3) { tblAddressPreview.Attributes["class"] = "AddressPreviewWithThreeColumns"; } }
/// <summary> /// Saves order information from ShoppingCartInfo object to database as new order. /// </summary> public override bool ProcessStep() { // Load first step if there is no currency or no address if ((this.ShoppingCartInfoObj.ShoppingCartBillingAddressID <= 0) || (this.ShoppingCartInfoObj.ShoppingCartCurrencyID <= 0)) { this.ShoppingCartControl.LoadStep(0); return(false); } // Deal with order note this.ShoppingCartControl.SetTempValue(ORDER_NOTE, null); this.ShoppingCartInfoObj.ShoppingCartNote = this.txtNote.Text.Trim(); try { // Set order culture ShoppingCartInfoObj.ShoppingCartCulture = CMSContext.PreferredCultureCode; // Update customer preferences CustomerInfoProvider.SetCustomerPreferredSettings(ShoppingCartInfoObj); // Create order ShoppingCartInfoProvider.SetOrder(this.ShoppingCartInfoObj); } catch (Exception ex) { lblError.Text = GetString("Ecommerce.OrderPreview.ErrorOrderSave") + " (" + ex.Message + ")"; return(false); } // Track order items conversions ECommerceHelper.TrackOrderItemsConversions(ShoppingCartInfoObj); // Track order conversion string name = this.ShoppingCartControl.OrderTrackConversionName; ECommerceHelper.TrackOrderConversion(ShoppingCartInfoObj, name); // Track order activity string siteName = CMSContext.CurrentSiteName; if (ActivitySettingsHelper.ActivitiesEnabledAndModuleLoaded(siteName) && this.LogActivityForCustomer && (this.ContactID > 0)) { // Track individual items if (ActivitySettingsHelper.PurchasedProductEnabled(siteName)) { this.ShoppingCartControl.TrackActivityPurchasedProducts(ShoppingCartInfoObj, siteName, this.ContactID); } // Tack entire purchase if (ActivitySettingsHelper.PurchaseEnabled(siteName)) { this.ShoppingCartControl.TrackActivityPurchase(ShoppingCartInfoObj.OrderId, this.ContactID, CMSContext.CurrentSiteName, URLHelper.CurrentRelativePath, ShoppingCartInfoObj.TotalPriceInMainCurrency, CurrencyInfoProvider.GetFormattedPrice(ShoppingCartInfoObj.TotalPriceInMainCurrency, CurrencyInfoProvider.GetMainCurrency(CMSContext.CurrentSiteID))); } } // Raise finish order event this.ShoppingCartControl.RaiseOrderCompletedEvent(); // When in CMSDesk if (this.ShoppingCartControl.IsInternalOrder) { if (chkSendEmail.Checked) { // Send order notification emails OrderInfoProvider.SendOrderNotificationToAdministrator(this.ShoppingCartInfoObj); OrderInfoProvider.SendOrderNotificationToCustomer(this.ShoppingCartInfoObj); } } // When on the live site else if (ECommerceSettings.SendOrderNotification(CMSContext.CurrentSite.SiteName)) { // Send order notification emails OrderInfoProvider.SendOrderNotificationToAdministrator(this.ShoppingCartInfoObj); OrderInfoProvider.SendOrderNotificationToCustomer(this.ShoppingCartInfoObj); } return(true); }
/// <summary> /// Returns SKU image URL including dimension's modifiers (width, height or maxsidesize) and site name parameter if product is from different site than current. If image URL is not specified, SKU default image URL is used. /// </summary> /// <param name="imageUrl">SKU image URL</param> /// <param name="width">Image requested width, has no effect if maxsidesize is specified</param> /// <param name="height">Image requested height, has no effect if maxsidesize is specified</param> /// <param name="maxsidesize">Image requested maximum side size</param> /// <param name="siteId">SKU site ID. If empty, current site ID is used.</param> public static string GetSKUImageUrl(object imageUrl, object width, object height, object maxsidesize, object siteId) { int iSiteId = ValidationHelper.GetInteger(siteId, 0); bool notCurrentSite = ((iSiteId > 0) && (iSiteId != CMSContext.CurrentSiteID)); string siteName = null; // Get site name if (notCurrentSite) { siteName = SiteInfoProvider.GetSiteName(iSiteId); } else { siteName = CMSContext.CurrentSiteName; } // Get product image URL string url = ValidationHelper.GetString(imageUrl, null); if (String.IsNullOrEmpty(url)) { // Get default product image URL url = ECommerceSettings.DefaultProductImageURL(siteName); } if (!String.IsNullOrEmpty(url)) { // Resolve URL url = URLHelper.ResolveUrl(url); int slashIndex = url.LastIndexOfCSafe('/'); if (slashIndex >= 0) { string urlStartPart = url.Substring(0, slashIndex); string urlEndPart = url.Substring(slashIndex); url = urlStartPart + HttpUtility.UrlPathEncode(urlEndPart); // Add site name if not current if (notCurrentSite) { url = URLHelper.AddParameterToUrl(url, "siteName", siteName); } // Add max side size int iMaxSideSize = ValidationHelper.GetInteger(maxsidesize, 0); if (iMaxSideSize > 0) { url = URLHelper.AddParameterToUrl(url, "maxsidesize", iMaxSideSize.ToString()); } else { // Add width int iWidth = ValidationHelper.GetInteger(width, 0); if (iWidth > 0) { url = URLHelper.AddParameterToUrl(url, "width", iWidth.ToString()); } // Add height int iHeight = ValidationHelper.GetInteger(height, 0); if (iHeight > 0) { url = URLHelper.AddParameterToUrl(url, "height", iHeight.ToString()); } } // Encode URL url = HTMLHelper.HTMLEncode(url); } } return(url); }
protected override void OnInit(EventArgs e) { base.OnInit(e); showProductsInTree = ECommerceSettings.DisplayProductsInSectionsTree(CurrentSiteName); if (NodeID > 0) { // Init document list docList.Node = DocumentHelper.GetDocument(NodeID, CultureCode, true, Tree); docList.Grid.GridName = "~/CMSModules/Ecommerce/Pages/Tools/Products/Product_List_Documents.xml"; docList.AdditionalColumns = "SKUID, DocumentSKUName, NodeParentID, NodeID, NodeSKUID, SKUName, SKUNumber, SKUPrice, SKUAvailableItems, SKUEnabled, SKUSiteID, SKUPublicStatusID, SKUInternalStatusID, SKUReorderAt"; docList.WhereCodition = GetDocumentWhereCondition(); docList.OrderBy = ShowSections ? "CASE WHEN NodeSKUID IS NULL THEN 0 ELSE 1 END, DocumentName" : "DocumentName"; docList.OnExternalAdditionalDataBound += gridData_OnExternalDataBound; docList.OnDocumentFlagsCreating += docList_OnDocumentFlagsCreating; docList.Grid.OnAction += gridData_OnAction; docList.Grid.RememberStateByParam = ""; docList.SelectLanguageJSFunction = "EditProductInCulture"; docList.DeleteReturnUrl = "~/CMSModules/Content/CMSDesk/Delete.aspx?multiple=true"; docList.PublishReturnUrl = "~/CMSModules/Content/CMSDesk/PublishArchive.aspx?multiple=true"; docList.ArchiveReturnUrl = "~/CMSModules/Content/CMSDesk/PublishArchive.aspx?multiple=true"; docList.TranslateReturnUrl = "~/CMSModules/Translations/Pages/TranslateDocuments.aspx"; if (!string.IsNullOrEmpty(ProductsStartingPath)) { docList.CopyMoveLinkStartingPath = ProductsStartingPath; } string languageSelectionScript = "function EditProductInCulture(nodeId, culture, translated, url) {parent.RefreshTree(nodeId, nodeId); window.location.href = 'Product_Edit_Frameset.aspx?nodeid='+nodeId+'&culture='+culture;}"; ScriptHelper.RegisterClientScriptBlock(this, typeof(string), "EditProductInCulture", ScriptHelper.GetScript(languageSelectionScript)); plcSKUListing.Visible = false; // Stop processing SKU table gridData.StopProcessing = true; EditedObject = docList.Node; // Set title string title = docList.Node.IsRoot() ? GetString("com.sku.productslist") : docList.Node.GetDocumentName(); SetTitle("Objects/Ecommerce_SKU/object.png", HTMLHelper.HTMLEncode(title), "product_list", "helpTopic"); } else { // Init Unigrid gridData.OnAction += gridData_OnAction; gridData.OnExternalDataBound += gridData_OnExternalDataBound; // Stop processing product document listing docList.StopProcessing = true; plcDocumentListing.Visible = false; // Set title according display tree setting if (DisplayTreeInProducts) { SetTitle("Objects/Ecommerce_SKU/object.png", GetString("com.sku.unassignedlist"), "stand_alone_SKUs_list", "helpTopic"); } else { SetTitle("Objects/Ecommerce_SKU/object.png", GetString("com.sku.productslist"), "SKUs_list", "helpTopic"); } } // Show warning when exchange rate from global main currency is missing if (AllowGlobalObjects && ExchangeTableInfoProvider.IsExchangeRateFromGlobalMainCurrencyMissing(CMSContext.CurrentSiteID)) { ShowWarning(GetString("com.NeedExchangeRateFromGlobal"), null, null); } }
/// <summary> /// Sends new registration notification e-mail to administrator. /// </summary> private void SendRegistrationNotification(UserInfo ui) { SiteInfo currentSite = SiteContext.CurrentSite; // Notify administrator if ((ui != null) && (currentSite != null) && (ShoppingCartControl.SendNewRegistrationNotificationToAddress != "")) { EmailTemplateInfo mEmailTemplate = null; if (!ui.UserEnabled) { mEmailTemplate = EmailTemplateProvider.GetEmailTemplate("Registration.Approve", currentSite.SiteName); } else { mEmailTemplate = EmailTemplateProvider.GetEmailTemplate("Registration.New", currentSite.SiteName); } if (mEmailTemplate == null) { // Email template not exist EventLogProvider.LogEvent(EventType.ERROR, "RegistrationForm", "GetEmailTemplate", eventUrl: RequestContext.RawURL); } else { // Initialize email message EmailMessage message = new EmailMessage(); message.EmailFormat = EmailFormatEnum.Default; message.From = EmailHelper.GetSender(mEmailTemplate, ECommerceSettings.SendEmailsFrom(currentSite.SiteName)); message.Subject = GetString("RegistrationForm.EmailSubject"); message.Recipients = ShoppingCartControl.SendNewRegistrationNotificationToAddress; message.Body = mEmailTemplate.TemplateText; // Init macro resolving string[,] replacements = new string[4, 2]; replacements[0, 0] = "firstname"; replacements[0, 1] = ui.FirstName; replacements[1, 0] = "lastname"; replacements[1, 1] = ui.LastName; replacements[2, 0] = "email"; replacements[2, 1] = ui.Email; replacements[3, 0] = "username"; replacements[3, 1] = ui.UserName; MacroResolver resolver = MacroContext.CurrentResolver; resolver.SetNamedSourceData(replacements); try { // Add template metafiles to e-mail EmailHelper.ResolveMetaFileImages(message, mEmailTemplate.TemplateID, EmailTemplateInfo.OBJECT_TYPE, ObjectAttachmentsCategories.TEMPLATE); // Send e-mail EmailSender.SendEmailWithTemplateText(currentSite.SiteName, message, mEmailTemplate, resolver, false); } catch { // Email sending failed EventLogProvider.LogEvent(EventType.ERROR, "Membership", "RegistrationEmail"); } } } }
private void OnProductSaved(object sender, EventArgs args) { if (!IsProductsUI) { // If not EditLive view mode, switch to form mode to keep editing the form if (PortalContext.ViewMode != ViewModeEnum.EditLive) { PortalContext.ViewMode = ViewModeEnum.EditForm; } } bool refreshEcommerceTree = (ECommerceSettings.ProductsTree(SiteContext.CurrentSiteName) == ProductsTreeModeEnum.Sections) && (ECommerceSettings.DisplayProductsInSectionsTree(SiteContext.CurrentSiteName)); if ((productEditElem.Product is TreeNode) && (!IsProductsUI || refreshEcommerceTree)) { var node = (TreeNode)productEditElem.Product; if (productEditElem.ProductSavedCreateAnother) { ScriptHelper.RefreshTree(this, node.NodeParentID, node.NodeParentID); ScriptHelper.RegisterStartupScript(Page, typeof(string), "Refresh", ScriptHelper.GetScript("CreateAnother();")); } else { ScriptHelper.RefreshTree(this, node.NodeParentID, node.NodeID); } } else if (productEditElem.ProductSavedCreateAnother) { RedirectToNewProduct(); } else { RedirectToSavedProduct(productEditElem.Product); } }
/// <summary> /// Checks currency rate combination. /// </summary> private void CheckCurrencyRateCombination() { if (ExchangeRatesCheck) { if (ECommerceSettings.UseGlobalExchangeRates(CMSContext.CurrentSiteName) && !ECommerceSettings.UseGlobalCurrencies(CMSContext.CurrentSiteName)) { DisplayMessage("com.settingschecker.wrongcurrencyratecombination"); } } }
/// <summary> /// Returns URL to the shopping cart. /// </summary> /// <param name="siteName">Site name</param> public static string ShoppingCartURL(string siteName) { return(URLHelper.ResolveUrl(ECommerceSettings.ShoppingCartURL(siteName))); }
/// <summary> /// Page load. /// </summary> protected void Page_Load(object sender, EventArgs e) { if (!this.StopProcessing) { if (CMSContext.CurrentUser.IsAuthenticated()) { // Get site id of credits main currency int creditSiteId = ECommerceHelper.GetSiteID(CMSContext.CurrentSiteID, ECommerceSettings.USE_GLOBAL_CREDIT); gridCreditEvents.HideControlForZeroRows = true; gridCreditEvents.IsLiveSite = this.IsLiveSite; gridCreditEvents.OnExternalDataBound += new OnExternalDataBoundEventHandler(gridCreditEvents_OnExternalDataBound); gridCreditEvents.OrderBy = "EventDate DESC, EventName ASC"; gridCreditEvents.WhereCondition = "EventCustomerID = " + this.CustomerId + " AND ISNULL(EventSiteID, 0) = " + creditSiteId; // Get total credit value double credit = CreditEventInfoProvider.GetTotalCredit(this.CustomerId, CMSContext.CurrentSiteID); if (Currency != null) { // Convert global credit to site main currency when using one string siteName = CMSContext.CurrentSiteName; rate = ExchangeRateInfoProvider.GetLastExchangeRate(Currency.CurrencyID, CMSContext.CurrentSiteID, ECommerceSettings.UseGlobalCredit(siteName)); credit = ExchangeRateInfoProvider.ApplyExchangeRate(credit, rate); } lblCreditValue.Text = CurrencyInfoProvider.GetFormattedPrice(credit, Currency); lblCredit.Text = GetString("Ecommerce.MyCredit.TotalCredit"); } else { // Hide if user is not authenticated this.Visible = false; } } }
protected override void OnLoad(EventArgs e) { base.OnLoad(e); EditedDocument = Node; // Get default relationship name from settings string defaultRelName = ECommerceSettings.RelatedProductsRelationshipName(SiteContext.CurrentSiteName); // Check if relationship exists bool anyRelationshipsFound = true; RelationshipNameInfo defaultRelNameInfo = RelationshipNameInfoProvider.GetRelationshipNameInfo(defaultRelName); if (defaultRelNameInfo != null) { relatedDocuments.RelationshipName = defaultRelName; } else { // Check if any relationship exists DataSet dsRel = RelationshipNameInfoProvider.GetRelationshipNames("RelationshipAllowedObjects LIKE '%" + ObjectHelper.GROUP_DOCUMENTS + "%' AND RelationshipNameID IN (SELECT RelationshipNameID FROM CMS_RelationshipNameSite WHERE SiteID = " + SiteContext.CurrentSiteID + ")", null, 1, "RelationshipNameID"); if (DataHelper.DataSourceIsEmpty(dsRel)) { relatedDocuments.Visible = false; ShowInformation(GetString("relationship.norelationship")); anyRelationshipsFound = false; } } if (anyRelationshipsFound && (Node != null)) { // Check read permissions if (MembershipContext.AuthenticatedUser.IsAuthorizedPerDocument(Node, NodePermissionsEnum.Read) == AuthorizationResultEnum.Denied) { RedirectToAccessDenied(string.Format(GetString("cmsdesk.notauthorizedtoreaddocument"), Node.NodeAliasPath)); } // Check modify permissions else if (MembershipContext.AuthenticatedUser.IsAuthorizedPerDocument(Node, NodePermissionsEnum.Modify) == AuthorizationResultEnum.Denied) { pnlDocInfo.Label.Text = string.Format(GetString("cmsdesk.notauthorizedtoeditdocument"), Node.DocumentName); relatedDocuments.Enabled = false; CurrentMaster.HeaderActions.Enabled = false; } } // Set tree node relatedDocuments.TreeNode = Node; // Set starting path if (!string.IsNullOrEmpty(ProductsStartingPath)) { relatedDocuments.StartingPath = ProductsStartingPath; } CurrentMaster.HeaderActions.ActionsList.Add(new HeaderAction { Text = GetString("relationship.addrelateddocs"), OnClientClick = relatedDocuments.GetAddRelatedDocumentScript() }); }
/// <summary> /// Retrieve the user password. /// </summary> private void btnPasswdRetrieval_Click(object sender, EventArgs e) { string value = txtPasswordRetrieval.Text.Trim(); if (!String.IsNullOrEmpty(value) && ValidationHelper.IsEmail(value) && (SiteContext.CurrentSite != null)) { AuthenticationHelper.ForgottenEmailRequest(value, SiteContext.CurrentSiteName, "ECOMMERCE", ECommerceSettings.SendEmailsFrom(SiteContext.CurrentSite.SiteName), null, AuthenticationHelper.GetResetPasswordUrl(SiteContext.CurrentSiteName)); lblResult.Text = String.Format(GetString("LogonForm.EmailSent"), value); plcResult.Visible = true; plcErrorResult.Visible = false; pnlPasswdRetrieval.Attributes.Add("style", "display:block;"); } else { lblErrorResult.Text = String.Format(GetString("LogonForm.EmailNotValid"), value); plcErrorResult.Visible = true; plcResult.Visible = false; pnlPasswdRetrieval.Attributes.Add("style", "display:block;"); } }
/// <summary> /// Sets data to database. /// </summary> protected void btnOK_Click(object sender, EventArgs e) { string errorMessage = ""; string siteName = SiteContext.CurrentSiteName; if ((txtCustomerCompany.Text.Trim() == "" || !IsBusiness) && ((txtCustomerFirstName.Text.Trim() == "") || (txtCustomerLastName.Text.Trim() == ""))) { errorMessage = GetString("Customers_Edit.errorInsert"); } // At least company name has to be filled when company account is selected if (errorMessage == "" && IsBusiness) { errorMessage = new Validator().NotEmpty(txtCustomerCompany.Text, GetString("customers_edit.errorCompany")).Result; } // Check the following items if complete company info is required for company account if (errorMessage == "" && ECommerceSettings.RequireCompanyInfo(siteName) && IsBusiness) { errorMessage = new Validator().NotEmpty(txtOraganizationID.Text, GetString("customers_edit.errorOrganizationID")) .NotEmpty(txtTaxRegistrationID.Text, GetString("customers_edit.errorTaxRegID")).Result; } if (errorMessage == "") { errorMessage = new Validator().IsEmail(txtCustomerEmail.Text.Trim(), GetString("customers_edit.erroremailformat"), true) .MatchesCondition(txtCustomerPhone.Text.Trim(), k => k.Length < 50, GetString("customers_edit.errorphoneformat")).Result; } plcCompanyInfo.Visible = IsBusiness; if (errorMessage == "") { // If customer doesn't already exist, create new one if (mCustomer == null) { mCustomer = new CustomerInfo(); mCustomer.CustomerUserID = MembershipContext.AuthenticatedUser.UserID; } mCustomer.CustomerEmail = txtCustomerEmail.Text.Trim(); mCustomer.CustomerLastName = txtCustomerLastName.Text.Trim(); mCustomer.CustomerPhone = txtCustomerPhone.Text.Trim(); mCustomer.CustomerFirstName = txtCustomerFirstName.Text.Trim(); mCustomer.CustomerCreated = DateTime.Now; if (IsBusiness) { mCustomer.CustomerCompany = txtCustomerCompany.Text.Trim(); mCustomer.CustomerOrganizationID = txtOraganizationID.Text.Trim(); mCustomer.CustomerTaxRegistrationID = txtTaxRegistrationID.Text.Trim(); } else { mCustomer.CustomerCompany = ""; mCustomer.CustomerOrganizationID = ""; mCustomer.CustomerTaxRegistrationID = ""; } // Update customer data CustomerInfoProvider.SetCustomerInfo(mCustomer); // Update corresponding contact data int currentContactId = ModuleCommands.OnlineMarketingGetCurrentContactID(); ModuleCommands.OnlineMarketingCreateRelation(mCustomer.CustomerID, MembershipType.ECOMMERCE_CUSTOMER, currentContactId); ContactInfoProvider.UpdateContactFromExternalData( mCustomer, DataClassInfoProvider.GetDataClassInfo(CustomerInfo.TYPEINFO.ObjectClassName).ClassContactOverwriteEnabled, currentContactId); // Let others now that customer was created if (OnCustomerCrated != null) { OnCustomerCrated(); ShowChangesSaved(); } else { URLHelper.Redirect(URLHelper.AddParameterToUrl(RequestContext.CurrentURL, "saved", "1")); } } else { //Show error ShowError(errorMessage); } }
/// <summary> /// Sends new registration notification e-mail to administrator. /// </summary> private void SendRegistrationNotification(UserInfo ui) { SiteInfo currentSite = SiteContext.CurrentSite; // Notify administrator if ((ui != null) && (currentSite != null) && (ShoppingCartControl.SendNewRegistrationNotificationToAddress != "")) { EmailTemplateInfo mEmailTemplate = null; if (!ui.UserEnabled) { mEmailTemplate = EmailTemplateProvider.GetEmailTemplate("Registration.Approve", currentSite.SiteName); } else { mEmailTemplate = EmailTemplateProvider.GetEmailTemplate("Registration.New", currentSite.SiteName); } EventLogProvider ev = new EventLogProvider(); if (mEmailTemplate == null) { // Email template not exist ev.LogEvent("E", DateTime.Now, "RegistrationForm", "GetEmailTemplate", HTTPHelper.GetAbsoluteUri()); } else { // Initialize email message EmailMessage message = new EmailMessage(); message.EmailFormat = EmailFormatEnum.Default; message.From = EmailHelper.GetSender(mEmailTemplate, ECommerceSettings.SendEmailsFrom(currentSite.SiteName)); message.Subject = GetString("RegistrationForm.EmailSubject"); message.Recipients = ShoppingCartControl.SendNewRegistrationNotificationToAddress; message.Body = mEmailTemplate.TemplateText; // Init macro resolving string[,] replacements = new string[4, 2]; replacements[0, 0] = "firstname"; replacements[0, 1] = ui.FirstName; replacements[1, 0] = "lastname"; replacements[1, 1] = ui.LastName; replacements[2, 0] = "email"; replacements[2, 1] = ui.Email; replacements[3, 0] = "username"; replacements[3, 1] = ui.UserName; ContextResolver resolver = MacroContext.CurrentResolver; resolver.SourceParameters = replacements; try { // Add template metafiles to e-mail MetaFileInfoProvider.ResolveMetaFileImages(message, mEmailTemplate.TemplateID, EmailObjectType.EMAILTEMPLATE, MetaFileInfoProvider.OBJECT_CATEGORY_TEMPLATE); // Send e-mail EmailSender.SendEmailWithTemplateText(currentSite.SiteName, message, mEmailTemplate, resolver, false); } catch { // Email sending failed ev.LogEvent("E", DateTime.Now, "Membership", "RegistrationEmail", SiteContext.CurrentSite.SiteID); } } } }
protected override void OnInit(EventArgs e) { base.OnInit(e); CMSContentPage.CheckSecurity(); // Check module permissions if (!ECommerceContext.IsUserAuthorizedForPermission("ReadProducts")) { RedirectToAccessDenied("CMS.Ecommerce", "EcommerceRead OR ReadProducts"); } SKUInfo sku = null; if (Node != null) { sku = SKUInfoProvider.GetSKUInfo(Node.NodeSKUID); } if ((sku != null) && (sku.SKUSiteID != SiteContext.CurrentSiteID) && ((sku.SKUSiteID != 0) || !ECommerceSettings.AllowGlobalProducts(SiteContext.CurrentSiteName))) { EditedObject = null; } productEditElem.ProductSaved += productEditElem_ProductSaved; string action = QueryHelper.GetString("action", string.Empty).ToLowerCSafe(); if (action == "newculture") { // Ensure breadcrumb for new culture version of product EnsureDocumentBreadcrumbs(PageBreadcrumbs, action: GetString("content.newcultureversiontitle")); } }