private ShoppingCartRuleResult PerformRules(ShoppingCart_V02 cart, ShoppingCartRuleReason reason, ShoppingCartRuleResult result) { if (reason == ShoppingCartRuleReason.CartCalculated) { result = CheckForInvalidSKUs(cart, result); result = CheckForDuplicateSKUs(cart, result); result = CheckForInvalidQuantities(cart, result); if (result.Result == RulesResult.Failure) { LoggerHelper.Error(string.Join("\r\n", result.Messages.ToArray())); } } //prevent to able to add products blocked by the skuToNoDisplayForNonQualifyMembers and EventId config key if (reason == ShoppingCartRuleReason.CartItemsBeingAdded) { var DSType = DistributorOrderingProfileProvider.CheckDsLevelType(cart.DistributorID, cart.Locale.Substring(3, 2)); if (DSType == ServiceProvider.DistributorSvc.Scheme.Member) { string errormessage = HttpContext.GetGlobalResourceObject("MyHL_ErrorMessage", "PMTypeRestrictOrdering").ToString(); result.AddMessage(errormessage); result.Result = RulesResult.Failure; } else { result = checkForConfigBlockedSKU(cart, result); } } return(result); }
protected void Page_Load(object sender, EventArgs e) { if (!HLConfigManager.Configurations.DOConfiguration.AllowHAP) { divHAPDisabled.Visible = true; divMainContent.Visible = false; } else if (!IsPostBack) { SessionInfo.IsHAPMode = false; ShoppingCart.HAPType = string.Empty; ShoppingCart.HAPScheduleDay = 0; ShoppingCart.HAPAction = ""; if (ShoppingCart.DsType == null) { var DistributorType = DistributorOrderingProfileProvider.CheckDsLevelType(DistributorID, CountryCode); ShoppingCart.DsType = DistributorType; } setNotificationMessage(); setHAPOrdersListView(); } (Master as OrderingMaster).gdoNavMidCSS("gdo-nav-mid col-md-12 gdo-nav-mid-cho"); (Master as OrderingMaster).SetPageHeader(GetLocalResourceObject("PageResource1.Title") as string); }
protected void Page_Load(object sender, EventArgs e) { if (ShoppingCart.DsType == null) { var DistributorType = DistributorOrderingProfileProvider.CheckDsLevelType(DistributorID, CountryCode); ShoppingCart.DsType = DistributorType; } if (ProductsBase.GlobalContext.CultureConfiguration.IsBifurcationEnabled && ShoppingCart.DsType == Scheme.Member) { ShoppingCart.HAPType = "01"; SessionInfo.HAPOrderType = "Personal"; } if (!IsPostBack) { bool isStatic = !string.IsNullOrEmpty(ShoppingCart.OrderNumber) && !string.IsNullOrEmpty(ShoppingCart.HAPType); pnlHAPOptions.Visible = !isStatic; pnlHAPOptionsStatic.Visible = isStatic; if (isStatic) { switch (ShoppingCart.HAPType) { case "01": lblOrderTypeSelected.Text = GetLocalResourceObject("PersonalRBText.Text").ToString(); break; case "02": lblOrderTypeSelected.Text = GetLocalResourceObject("ResaleRBText.Text").ToString(); break; } switch (ShoppingCart.HAPScheduleDay) { case 4: lblScheduleSelected.Text = GetLocalResourceObject("rb1Option.Text").ToString(); break; case 11: lblScheduleSelected.Text = GetLocalResourceObject("rb2Option.Text").ToString(); break; case 18: lblScheduleSelected.Text = GetLocalResourceObject("rb3Option.Text").ToString(); break; } } else { if (ProductsBase.GlobalContext.CultureConfiguration.IsBifurcationEnabled) { tbHAPOrderType.Visible = false; } else { var oHAPOrders = (Page as ProductsBase).ActiveHAPOrders; bool hasPersonalHAPOrder = false; bool hasResaleHAPOrder = false; if (oHAPOrders != null && oHAPOrders.Count > 0) { hasPersonalHAPOrder = oHAPOrders.Any(i => i.HapOrderProgramType == "01"); hasResaleHAPOrder = oHAPOrders.Any(i => i.HapOrderProgramType == "02"); rbPersonal.Visible = !hasPersonalHAPOrder; rbResale.Visible = !hasResaleHAPOrder; } switch (ShoppingCart.HAPType) { case "01": rbPersonal.Checked = true; break; case "02": rbResale.Checked = true; break; } } if (ShoppingCart.HAPScheduleDay > 0) { switch (ShoppingCart.HAPScheduleDay) { case 4: rb1.Checked = true; break; case 11: rb2.Checked = true; break; case 18: rb3.Checked = true; break; } } } } //10. HAP orders deadline dates are: //o US 11th and 18th //o CA 4th, 11th and 18th if (CountryCode == "US") { rb1.Visible = false; rb1.Enabled = false; } else if (CountryCode == "CA") { rb1.Visible = true; rb1.Enabled = true; } }
private ShoppingCartRuleResult CanAddProducts(ref ShoppingCart_V02 cart, ShoppingCartRuleResult result) { //i. A China MB cannot setup HAP order for US or Canada if (DistributorProfileModel.ProcessingCountry == "CN") { result.Result = RulesResult.Errors; result.AddMessage(HttpContext.GetGlobalResourceObject( string.Format("{0}_ErrorMessage", HLConfigManager.Platform), "CantOrder") as string); } MyHLShoppingCart myCart = cart as MyHLShoppingCart; if (myCart.ItemsBeingAdded == null || myCart.ItemsBeingAdded.Count == 0) { return(result); } if (myCart.DsType == null) { var DistributorType = DistributorOrderingProfileProvider.CheckDsLevelType(cart.DistributorID, Country); myCart.DsType = DistributorType; } if (globalContext.CultureConfiguration.IsBifurcationEnabled) { if (myCart.DsType == Scheme.Member) { myCart.HAPType = "01"; } else { var session = SessionInfo.GetSessionInfo(myCart.DistributorID, Locale); if (session != null && session.HAPOrderType != null) { if (session.HAPOrderType == "Personal") { myCart.HAPType = "01"; } else if (session.HAPOrderType == "RetailOrder") { myCart.HAPType = "02"; } } } } if (string.IsNullOrEmpty(myCart.HAPType)) { result.Result = RulesResult.Failure; result.AddMessage(HttpContext.GetGlobalResourceObject( string.Format("{0}_ErrorMessage", HLConfigManager.Platform), "MissingHapType") as string); myCart.ItemsBeingAdded.Clear(); return(result); } if (myCart.HAPScheduleDay == 0) { result.Result = RulesResult.Failure; result.AddMessage(HttpContext.GetGlobalResourceObject( string.Format("{0}_ErrorMessage", HLConfigManager.Platform), "MissingHapDate") as string); myCart.ItemsBeingAdded.Clear(); return(result); } //calculate VP var vp = getTotalvolumePoints(myCart, this.Country); // Generic HAP Order rules // HAP orders are allowed for Product type (“P”) items only if (!verifyProducttypes(myCart, this.Country)) { result.Result = RulesResult.Failure; result.AddMessage(HttpContext.GetGlobalResourceObject( string.Format("{0}_ErrorMessage", HLConfigManager.Platform), "HAPOrderAddingNonProducts") as string); myCart.ItemsBeingAdded.Clear(); } // Validate is not expired if (isExpired(cart)) { result.Result = RulesResult.Failure; result.AddMessage(HttpContext.GetGlobalResourceObject( string.Format("{0}_ErrorMessage", HLConfigManager.Platform), "HAPOrderExpired") as string); myCart.ItemsBeingAdded.Clear(); } // Personal HAP Order // Personal HAP order is allowed a maximum of 1000 VP // There is a Maximum quantity of 6 for any individual selling SKU on personal consumption HAP orders //check if is a personal hap order with order subtype //01 = Personal / 02 = Resale if (myCart.HAPType == "01") { if (vp > MAX_VP) { result.Result = RulesResult.Failure; result.AddMessage(HttpContext.GetGlobalResourceObject( string.Format("{0}_ErrorMessage", HLConfigManager.Platform), myCart.DsType == Scheme.Member ? "HAPOrderExceedVPForMB" : "HAPOrderExceedVP") as string); myCart.ItemsBeingAdded.Clear(); } if (myCart.ItemsBeingAdded != null && myCart.ItemsBeingAdded.Count > 0) { foreach (var a in myCart.ItemsBeingAdded) { var itemInCard = cart.CartItems.Find(c => c.SKU == a.SKU); if (globalContext.CultureConfiguration.IsBifurcationEnabled && myCart.DsType == Scheme.Member) { if (a.Quantity > 4 || (itemInCard != null && (itemInCard.Quantity + a.Quantity) > 4)) { result.Result = RulesResult.Failure; result.AddMessage(HttpContext.GetGlobalResourceObject( string.Format("{0}_ErrorMessage", HLConfigManager.Platform), "HAPOrderExceedSKUForMember") as string); myCart.ItemsBeingAdded.Clear(); break; } } else if (a.Quantity > 6 || (itemInCard != null && (itemInCard.Quantity + a.Quantity) > 6)) { result.Result = RulesResult.Failure; result.AddMessage(HttpContext.GetGlobalResourceObject( string.Format("{0}_ErrorMessage", HLConfigManager.Platform), "HAPOrderExceedSKU") as string); myCart.ItemsBeingAdded.Clear(); break; } } } } // Resale HAP Order //For HAP Resale, there is a minimum order restriction of 100 VP, but there is no maximum VP limit and no SKU quantity limitations return(result); }
protected void Page_Load(object sender, EventArgs e) { if (HLConfigManager.Configurations.DOConfiguration.IsChina && !SessionInfo.IsReplacedPcOrder) { var SurveyEligibility = Providers.China.OrderProvider.GetCustomerSurvey(DistributorID); if (SurveyEligibility != null) { if (Session["CustomerSurveyCancelled"] == null || !Convert.ToBoolean(Session["CustomerSurveyCancelled"])) { Response.Redirect("Survey.aspx?@ctrl=CustomerSurvey"); } } else if (SessionInfo.surveyDetails != null && ShoppingCart.CartItems.Any() && ShoppingCart.CartItems.Find( x => x.SKU == SessionInfo.surveyDetails.SurveySKU.Trim()) == null && !SessionInfo.surveyDetails.SurveyCompleted) { Providers.China.OrderProvider.AddFreeGift( SessionInfo.surveyDetails.SurveySKU.Trim(), SessionInfo.surveyDetails.SurveySKUQuantity, ProductInfoCatalog.AllSKUs, ShoppingCart.DeliveryInfo.WarehouseCode, ShoppingCart); } } (Master as OrderingMaster).SetPageHeader(GetLocalResourceObject("PageHeaderProducts").ToString()); if (ShoppingCart.OrderCategory == OrderCategoryType.ETO) { (Master as OrderingMaster).SetPageHeader(GetLocalResourceObject("PageHeaderEvents").ToString()); } if (!String.IsNullOrEmpty(HLConfigManager.Configurations.CheckoutConfiguration.CheckoutOptionsControl)) { var _checkoutOptionsControl = LoadControl(HLConfigManager.Configurations.CheckoutConfiguration.CheckoutOptionsControl); _checkoutOptions = _checkoutOptionsControl as CheckOutOptions; _checkoutOptions.IsStatic = (Page as ProductsBase).CheckoutOptionsAreStatic; plCartOptions.Controls.Add(_checkoutOptions); } if (!String.IsNullOrEmpty(HLConfigManager.Configurations.CheckoutConfiguration.CheckoutTotalsMiniControl)) { var _checkoutTotalsMini = LoadControl(HLConfigManager.Configurations.CheckoutConfiguration.CheckoutTotalsMiniControl); plCheckOutTotalsMini.Controls.Add(_checkoutTotalsMini); } if (!String.IsNullOrEmpty(HLConfigManager.Configurations.CheckoutConfiguration.CheckOutHAPOptionsControl) && HLConfigManager.Configurations.DOConfiguration.AllowHAP && ShoppingCart.OrderCategory == OrderCategoryType.HSO) { var _checkoutHAPOptions = LoadControl(HLConfigManager.Configurations.CheckoutConfiguration.CheckOutHAPOptionsControl); plCheckOutHAPOptions.Controls.Add(_checkoutHAPOptions); if (ShoppingCart.DsType == null) { var DistributorType = DistributorOrderingProfileProvider.CheckDsLevelType(DistributorID, CountryCode); ShoppingCart.DsType = DistributorType; } } if (!String.IsNullOrEmpty(HLConfigManager.Configurations.CheckoutConfiguration.CheckoutOrderSummary)) { _checkoutOrderSummary = LoadControl(HLConfigManager.Configurations.CheckoutConfiguration.CheckoutOrderSummary) as CheckoutOrderSummary; _checkoutOrderSummary.DisplayReadOnlyGrid = false; _checkoutOrderSummary.OmnitureState = "scView"; plCheckOutOrderDetails.Controls.Add(_checkoutOrderSummary); } if (!IsPostBack) { // display cart name if (HLConfigManager.Configurations.DOConfiguration.AllowSavedCarts) { if (ShoppingCart != null && ShoppingCart.IsSavedCart && !ShoppingCart.IsFromCopy && !string.IsNullOrEmpty(ShoppingCart.CartName)) { SavedCartTitle.Visible = true; lblSavedCartName.Text = string.Format(GetLocalResourceObject("lblSavedCartName").ToString(), ShoppingCart.CartName); } } if (ShoppingCart != null && ShoppingCart.CartItems != null && ShoppingCart.CartItems.Count > 0) { if (ShoppingCart.DeliveryInfo != null) { var skuList = new List <SKU_V01>(); skuList.AddRange(from s in ShoppingCart.CartItems from k in AllSKUS where s.SKU == s.SKU select k.Value); CatalogProvider.GetProductAvailability(skuList, Locale, DistributorID, ShoppingCart.DeliveryInfo.WarehouseCode); } findCrossSell(ShoppingCart.CartItems); if (ShoppingCart.CustomerOrderDetail != null) { divcustomerOrderStaticMessage.Visible = true; lblCustomerOrderStaticMessage.Text = GetLocalResourceObject("CustomerOrderStaticMessage").ToString(); } } else { NoCrossSellFound(this, null); } // Process copy invoice var invoiceId = Request.QueryString["invoiceId"]; if (!string.IsNullOrEmpty(invoiceId) || IsFromMemberInvoice()) { var isCopingFromInvoice = Session["IsCopingFromInvoice"] as string; if (!string.IsNullOrEmpty(isCopingFromInvoice) && isCopingFromInvoice.Equals("Y")) { // Save the active cart if needed if (ShoppingCart.CartItems.Count != 0 && !ShoppingCart.IsSavedCart) { txtSaveCartName.Text = SaveCartCommand.SuggestCartName(ShoppingCart.DeliveryInfo, string.Empty, DistributorID, Locale); mdlClearCart.Show(); } else { CopyInvoice(); } } } if (HLConfigManager.Configurations.DOConfiguration.IsChina) { HLRulesManager.Manager.ProcessCart(ShoppingCart, ShoppingCartRuleReason.CartItemsAdded); } var allowedCountries = HL.Common.Configuration.Settings.GetRequiredAppSetting("AllowAPFPopupForStandAloneContries", "CH"); if (Session["showedAPFPopup"] == null) { Session["showedAPFPopup"] = false; } if (!(bool)Session["showedAPFPopup"] && allowedCountries.Contains(Locale.Substring(3)) && (APFDueProvider.IsAPFDueWithinOneYear(DistributorID, Locale.Substring(3)) || APFDueProvider.IsAPFDueAndNotPaid(DistributorID, Locale))) { APFDuermndrPopUp.ShowPopUp(); } if (HLConfigManager.Configurations.AddressingConfiguration.HasAddressRestriction) { List <DeliveryOption> shippingAddresses = (Page as ProductsBase).GetShippingProvider() .GetShippingAddresses((Page as ProductsBase).DistributorID, (Page as ProductsBase).Locale) .Where(s => s.HasAddressRestriction == true) .ToList(); if (shippingAddresses.Count == 0) { AddressResPopUP1.ShowAddressRestrictionPopUp(); } } } if (HLConfigManager.Configurations.DOConfiguration.IsChina && DistributorOrderingProfile.IsTermConditionAlert) { // TermConditionPopupExtender.Show(); } (Master as OrderingMaster).SetDivSpacerVisibility(false); (Master as OrderingMaster).SetHeaderRowVisibility(false); //(this.Master as OrderingMaster).SetRightPanelStyle("margin", "13px 8px"); if (HLConfigManager.Configurations.DOConfiguration.IsResponsive && (Master as OrderingMaster).IsMobile()) { (Master as OrderingMaster).divLeftVisibility = true; } else { (Master as OrderingMaster).divLeftVisibility = false; } (Master as OrderingMaster).gdoNavMidCSS("gdo-nav-mid col-xs-12 col-sm-9 gdo-nav-mid-sp"); var strScript1 = @"$(document).ready(function() { scrollTo(0, 0); });"; ScriptManager.RegisterStartupScript(this, GetType(), "ScriptPopup", strScript1, true); DisplayELearningMessage(); if (HLConfigManager.Configurations.DOConfiguration.AllowHAP && SessionInfo.IsHAPMode && !string.IsNullOrEmpty(ShoppingCart.HAPAction) && ShoppingCart.HAPAction == "UPDATE") { divHapEditMessage.Visible = true; } if (HLConfigManager.Configurations.DOConfiguration.CheckSKUExpirationDate) { ExpireDatePopUp1.ShowPopUp(); } }