private List <ShoppingCartItem_V01> CartHasOnlyTodaysMagazine(List <ShoppingCartItem_V01> items) { bool hasOnlyMagazine = false; var mags = new List <ShoppingCartItem_V01>(); string primarySku = HLConfigManager.Configurations.DOConfiguration.TodayMagazineSku; string secondarySku = HLConfigManager.Configurations.DOConfiguration.TodayMagazineSecondarySku; int numMags = (from c in items where c.SKU == primarySku || c.SKU == secondarySku select c).Count(); if (numMags > 0) { if ((from i in items where APFDueProvider.GetAPFSkuList().Contains(i.SKU) select i).Count() > 0) { if (items.Count == numMags + 1) { hasOnlyMagazine = true; } } } if (hasOnlyMagazine) { mags.AddRange((from i in items where i.SKU == primarySku || i.SKU == secondarySku select i).ToList()); } return(mags); }
private ShoppingCartRuleResult ShippingTemperatureControlled(ShoppingCart_V01 cart, ShoppingCartRuleResult Result) { var SKUIds = new List <string> { "Q638", "Q639", "Q640", "Q641" }; if (!SKUIds.Any(s => s == cart.CurrentItems[0].SKU)) { return(Result); } try { var x = (from a in APFDueProvider.GetAPFSkuList() from b in cart.CartItems from c in SKUIds where b.SKU != c && b.SKU != a && b.SKU != HLConfigManager.Configurations.DOConfiguration.HFFHerbalifeSku select b); if (x.Count() > 0) { Result.Result = RulesResult.Feedback; Result.AddMessage( string.Format( "Il codice {0} non può essere ordinato insieme ad altri prodotti. Se hai già inserito altri prodotti nel carrello, rimuovili prima di completare il tuo ordine. La mancata rimozione dal carrello degli altri prodotti comporterà la cancellazione e l'eventuale rimborso dell'ordine stesso", cart.CurrentItems[0].SKU)); cart.RuleResults.Add(Result); } } catch { } return(Result); }
protected void ddl_OrderType_SelectedIndexChanged(object sender, EventArgs e) { if (!String.IsNullOrEmpty(ddl_OrderType.SelectedItem.Value)) { OnOrderSubTypeChanged(sender, e); //bool refresh = false; PurchasingLimits_V01 limits = PurchasingLimitProvider.GetPurchasingLimits(DistributorID, ddl_OrderType.SelectedItem.Value); ShoppingCart.SelectedDSSubType = ddl_OrderType.SelectedItem.Value; lblOrderTypeVal.Text = ddl_OrderType.SelectedItem.ToString(); //If the order type is switched to Resale and DS has added APFs to cart, throw them out if (ddl_OrderType.SelectedItem.Value == OrderTypesBG.CO.ToString() && APFDueProvider.IsAPFSkuPresent(ShoppingCart.CartItems) && !APFDueProvider.IsAPFDueAndNotPaid(DistributorID, Locale)) { ShoppingCart.DeleteItemsFromCart(APFDueProvider.GetAPFSkuList()); // refresh = true; } if (ShoppingCart.CartItems.Count > 0) { List <ShoppingCartRuleResult> results = HLRulesManager.Manager.ProcessCart(ShoppingCart, ShoppingCartRuleReason .CartCalculated); if (results.Count > 0 && results.Any(r => r.Result == RulesResult.Failure)) { foreach (ShoppingCartRuleResult result in results) { if (result.Result == RulesResult.Failure) { var args = new CartModifiedForSKULimitationsEventArgs(result.Messages[0]); OnCartItemRemovedDueToSKULimitationRules(this, args); } } } } if (HasMemberVPLimitations()) { PurchaseLimitType limitType = PurchaseLimitType.Volume; limits.PurchaseLimitType = limitType; DisplayRemaining(ShoppingCart.SelectedDSSubType); } else { PurchaseLimitType limitType = PurchaseLimitType.None; limits.PurchaseLimitType = limitType; } } else { ShoppingCart.SelectedDSSubType = String.Empty; trRemainingVal.Visible = false; lblOrderTypeVal.Text = String.Empty; } }
private bool SetFreightCodesForIBPOrders(MyHLShoppingCart thisCart) { bool isIbp = false; if (string.IsNullOrEmpty(HLConfigManager.Configurations.DOConfiguration.IBPSku)) { return(isIbp); } var ibpSkus = HLConfigManager.Configurations.DOConfiguration.IBPSku.Split(',').ToList(); string oldFreightCode = thisCart.DeliveryInfo.FreightCode; if (thisCart.CartItems.Any() && thisCart.Totals != null) { if (thisCart.CartItems.Any(i => ibpSkus.Contains(i.SKU))) { isIbp = true; var state = (thisCart.DeliveryInfo.Address.Address.StateProvinceTerritory ?? string.Empty).Trim(); var city = (thisCart.DeliveryInfo.Address.Address.City ?? string.Empty).Trim(); // Check if it's a major city if (IsMajorCity(state, city)) { thisCart.DeliveryInfo.FreightCode = "FSL"; } else { thisCart.DeliveryInfo.FreightCode = "IND"; } //check IBP with APF (User Story 164536) var apfSkus = APFDueProvider.GetAPFSkuList(); var thisSkus = thisCart.CartItems.Select(x => x.SKU).ToList(); thisSkus = thisSkus.Except(apfSkus).ToList(); var nonHAP = thisSkus.Except(ibpSkus).ToList(); if (thisCart.CartItems.Any(i => apfSkus.Contains(i.SKU))) { thisCart.DeliveryInfo.FreightCode = "NOF"; } } } if (thisCart.DeliveryInfo.FreightCode != oldFreightCode) { ShoppingCartProvider.UpdateShoppingCart(thisCart); // save to database } return(isIbp); }
private ShoppingCartRuleResult CartItemAddedRuleHandler(ShoppingCart_V01 cart, ShoppingCartRuleResult result, string level) { var distributorId = cart.DistributorID; var isAPFDueandNotPaid = APFDueProvider.IsAPFDueAndNotPaid(distributorId, Locale); if (isAPFDueandNotPaid && HLConfigManager.Configurations.DOConfiguration.IsChina) { string cacheKey = string.Empty; bool reloadAPFs = (null != cart && null != cart.CartItems) && isAPFDueandNotPaid && !APFDueProvider.IsAPFSkuPresent(cart.CartItems); cart.APFEdited = false; DoApfDue(cart.DistributorID, cart, cacheKey, Locale, reloadAPFs, result, true); } try { var hlCart = cart as MyHLShoppingCart; if (null != hlCart) { var isPlacing = !String.IsNullOrWhiteSpace(hlCart.SrPlacingForPcOriginalMemberId); if (isPlacing) { var skuList = APFDueProvider.GetAPFSkuList(); if (skuList != null && skuList.Count > 0) { var items = (from s in skuList from c in cart.CartItems where s == c.SKU select c.SKU).ToList(); if (null != items && items.Count > 0) { hlCart.DeleteItemsFromCart(items, true); } } } } } catch (Exception ex) { LoggerHelper.Error( string.Format("APFRules.CartItemAddedRuleHandler DS:{0} locale:{2} ERR:{1}", cart.DistributorID, ex, Locale)); } return(result); }
protected void CartItemListView_ItemDataBound(object sender, ListViewItemEventArgs e) { if (e.Item.ItemType == ListViewItemType.DataItem) { var prodDesc = (LinkButton)e.Item.FindControl("LinkProductDetail"); var hdnSKU = (HiddenField)e.Item.FindControl("hdnSKU"); var nonLinkedSkus = APFDueProvider.GetAPFSkuList(); if (!String.IsNullOrEmpty(HLConfigManager.Configurations.DOConfiguration.HFFHerbalifeSku)) { nonLinkedSkus.Add(HLConfigManager.Configurations.DOConfiguration.HFFHerbalifeSku); } if (!String.IsNullOrEmpty(HLConfigManager.Configurations.DOConfiguration.TodayMagazineSku)) { nonLinkedSkus.Add(HLConfigManager.Configurations.DOConfiguration.TodayMagazineSku); } if (!String.IsNullOrEmpty(HLConfigManager.Configurations.DOConfiguration.TodayMagazineSecondarySku)) { nonLinkedSkus.Add(HLConfigManager.Configurations.DOConfiguration.TodayMagazineSecondarySku); } if (prodDesc != null && hdnSKU != null) { if (nonLinkedSkus.Contains(hdnSKU.Value)) { prodDesc.OnClientClick = "return false;"; prodDesc.CommandArgument = "disable"; prodDesc.CssClass = "disable-link"; } if (IsChina) { //Extra checking to ensure the command argument being updated properly for the item without product info. if (string.IsNullOrEmpty(prodDesc.CommandArgument) || prodDesc.CommandArgument.Trim() == string.Empty) { prodDesc.OnClientClick = "return false;"; prodDesc.CommandArgument = "disable"; prodDesc.CssClass = "disable-link"; } } if (ProductsBase.GlobalContext.CultureConfiguration.IsBifurcationEnabled && SessionInfo.DsType == ServiceProvider.DistributorSvc.Scheme.Member && SessionInfo.IsHAPMode == true) { prodDesc.OnClientClick = "return false;"; prodDesc.CommandArgument = "disable"; prodDesc.CssClass = "disable-link"; } } } }
protected void ddl_DSSubType_SelectedIndexChanged(object sender, EventArgs e) { if (!String.IsNullOrEmpty(ddl_DSSubType.SelectedItem.Value)) { bool refresh = false; PurchasingLimits_V01 limits = PurchasingLimitProvider.GetPurchasingLimits(DistributorID, ddl_DSSubType.SelectedItem.Value); ShoppingCart.SelectedDSSubType = ddl_DSSubType.SelectedItem.Value; //If the order type is switched to Resale and DS has added APFs to cart, throw them out if (limits.PurchaseType == OrderPurchaseType.Consignment && APFDueProvider.IsAPFSkuPresent(ShoppingCart.CartItems) && !APFDueProvider.IsAPFDueAndNotPaid(DistributorID, Locale)) { ShoppingCart.DeleteItemsFromCart(APFDueProvider.GetAPFSkuList()); refresh = true; } if (ShoppingCart.CartItems.Count > 0) { List <ShoppingCartRuleResult> results = HLRulesManager.Manager.ProcessCart(ShoppingCart, ShoppingCartRuleReason.CartCalculated); if (results.Count > 0 && results.Any(r => r.Result == RulesResult.Failure)) { foreach (ShoppingCartRuleResult result in results) { if (result.Result == RulesResult.Failure) { CartModifiedForSKULimitationsEventArgs args = new CartModifiedForSKULimitationsEventArgs(result.Messages[0]); OnCartItemRemovedDueToSKULimitationRules(this, args); } } } ShoppingCart.Calculate(); OnOrderSubTypeChanged(this, new OrderSubTypeEventArgs(ddl_DSSubType.SelectedItem.Value, true, false, true)); } DisplayRemainingValues(ddl_DSSubType.SelectedItem.Value, refresh); lblMessageZeroPercent.Visible = ShoppingCart.SelectedDSSubType == "RE"; } else { ShoppingCart.SelectedDSSubType = String.Empty; trRemainingVal.Visible = false; } }
private ShoppingCartItem_V01 GetApfSku(List <ShoppingCartItem_V01> cartItems, string locale, string level) { ShoppingCartItem_V01 sku = null; var SKUs = APFDueProvider.GetAPFSkuList(); if (SKUs != null && SKUs.Count == 2) { // if sku does not exist in the cart, add it // sku 1 is SP //string apfSKU = level == "SP" ? SKUs[1] : SKUs[0]; string apfSKU = string.Empty; if (level == "SP") { apfSKU = HLConfigManager.Configurations.APFConfiguration.SupervisorSku; } else { apfSKU = HLConfigManager.Configurations.APFConfiguration.DistributorSku; } sku = new ShoppingCartItem_V01(0, apfSKU, 1, DateTime.Now); } return(sku); }
// private void SetApfRuleResponse() #region Event methods private ShoppingCartRuleResult CartRetrievedRuleHandler(ShoppingCart_V01 cart, ShoppingCartRuleResult result, string level) { string key = string.Format("{0}_{1}_{2}", "JustEntered", cart.DistributorID, Locale); bool justEntered = (Session != null && ((null != Session[key]))) ? (bool)Session[key] : true; if (Session != null) { Session[key] = null; } string cacheKey = string.Empty; ////ShoppingCartProvider.GetCacheKey(distributor.Value.ID, Locale); bool reloadAPFs = (null != cart && null != cart.CartItems) && APFDueProvider.IsAPFDueAndNotPaid(cart.DistributorID, Locale) && !APFDueProvider.IsAPFSkuPresent(cart.CartItems); if (null == cart || null == cart.CartItems || cart.CartItems.Count == 0 || reloadAPFs || APFDueProvider.IsAPFSkuPresent(cart.CartItems)) { try { if (null != cart) { if (APFDueProvider.IsAPFDueAndNotPaid(cart.DistributorID, Locale)) { if (justEntered || !cart.APFEdited) { DoApfDue(cart.DistributorID, cart, cacheKey, Locale, reloadAPFs, result, justEntered); } } else { if (APFDueProvider.IsAPFSkuPresent(cart.CartItems)) { var currentSession = SessionInfo.GetSessionInfo(cart.DistributorID, cart.Locale); if ((!cart.APFEdited || !APFDueProvider.CanEditAPFOrder(cart.DistributorID, Locale, level)) && (currentSession != null && !currentSession.IsAPFOrderFromPopUp)) { var skuList = APFDueProvider.GetAPFSkuList(); if (skuList != null && skuList.Count > 0) { var hlCart = cart as MyHLShoppingCart; if (null != hlCart) { var items = (from s in skuList from c in cart.CartItems where s == c.SKU select c.SKU).ToList(); if (null != items && items.Count > 0) { hlCart.DeleteItemsFromCart(items); } } } } } } } } catch (Exception ex) { LoggerHelper.Error( string.Format("APFRules.ProcessAPF DS:{0} locale:{2} ERR:{1}", cart.DistributorID, ex, Locale)); } } return(result); }
private ShoppingCartRuleResult RemovePromoOnEmptyCart(MyHLShoppingCart shoppingCart, ShoppingCartRuleResult result) { var promo = ShoppingCartProvider.GetEligibleForPromo(shoppingCart.DistributorID, shoppingCart.Locale); PromoSKUs = HLConfigManager.Configurations.ShoppingCartConfiguration.PromotionalSku.Split(',').ToList(); var promoSkuInCart = promo != null? shoppingCart.CartItems.Where(i => i.SKU == promo.Sku).Select(i => i.SKU).ToList() : shoppingCart.CartItems.Where(i => PromoSKUs.Contains(i.SKU)).Select(i => i.SKU).ToList(); shoppingCart.IsPromoNotified = !promoSkuInCart.Any(); if (shoppingCart.DeliveryInfo != null && shoppingCart.DeliveryInfo.Option != ServiceProvider.ShippingSvc.DeliveryOptionType.Shipping) { // Remove promo if it is in cart if (promoSkuInCart.Any()) { shoppingCart.DeleteItemsFromCart(promoSkuInCart, true); shoppingCart.IsPromoDiscarted = true; result.Result = RulesResult.Success; shoppingCart.RuleResults.Add(result); return(result); } else { result.Result = RulesResult.Success; shoppingCart.RuleResults.Add(result); return(result); } } if ((promo != null && !shoppingCart.CartItems.Any(i => promo.Sku != i.SKU)) || (promo == null && !shoppingCart.CartItems.Any(i => PromoSKUs.Contains(i.SKU)))) { shoppingCart.DeleteItemsFromCart(promoSkuInCart, true); shoppingCart.IsPromoDiscarted = true; result.Result = RulesResult.Success; shoppingCart.RuleResults.Add(result); return(result); } // Validate if the cart has only HFF and/or APF item var HFFsku = HLConfigManager.Configurations.DOConfiguration.HFFHerbalifeSku; var apfSkus = APFDueProvider.GetAPFSkuList(); if (HFFsku != null && shoppingCart.CartItems.Any(i => i.SKU == HFFsku || apfSkus.Contains(i.SKU))) { if (promo != null && !shoppingCart.CartItems.Any(i => i.SKU != HFFsku && i.SKU != promo.Sku && !apfSkus.Contains(i.SKU))) { shoppingCart.IsPromoDiscarted = true; if (promoSkuInCart.Count > 0) { // Remove promoSkus from cart, cant apply for promo when have HFF SKU only shoppingCart.DeleteItemsFromCart(promoSkuInCart, true); } // Just remove promo sku and nothing more to do LoggerHelper.Info("No promo sku added when only HFF SKU is in cart"); result.Result = RulesResult.Success; shoppingCart.RuleResults.Add(result); return(result); } } return(result); }
private void displayBadgePromo() { divPromo.Visible = false; List <CatalogItem> badgePromoList = new List <CatalogItem>(); Dictionary <string, SKU_V01> allsku = null; if (ShoppingCart != null && ShoppingCart.CartItems.Any()) { if (ShoppingCart.DeliveryInfo == null || string.IsNullOrEmpty(ShoppingCart.DeliveryInfo.WarehouseCode)) { return; } if (CatalogProvider.IsPreordering(ShoppingCart.CartItems, ShoppingCart.DeliveryInfo.WarehouseCode)) { return; } if (!(ShoppingCart.OrderCategory == ServiceProvider.CatalogSvc.OrderCategoryType.RSO)) { return; } if (APFDueProvider.hasOnlyAPFSku(ShoppingCart.CartItems, Locale)) { return; } } else { divPromo.Visible = false; promotionPanel.Update(); return; } //var profile = DistributorOrderingProfileProvider.GetProfile(ShoppingCart.DistributorID, ShoppingCart.DeliveryInfo.Address.Address.Country); var memberId = String.IsNullOrEmpty(ShoppingCart.SrPlacingForPcOriginalMemberId) ? ShoppingCart.DistributorID : ShoppingCart.SrPlacingForPcOriginalMemberId; if (ChinaPromotionProvider.IsEligibleForBadgePromotion(ShoppingCart, HLConfigManager.Platform, memberId)) { var cacheKey = string.Format("GetBadgePromoDetail_{0}", memberId); var results = HttpRuntime.Cache[cacheKey] as GetBadgePinResponse_V01; if (results != null) { var badgeList = results.BadgeDetails; if (results != null && badgeList.Length > 0) { if (ShoppingCart != null && ShoppingCart.CartItems.Count > 0) { if (cblFreeGiftlist.Items.Count > 0) { cblFreeGiftlist.Items.Clear(); } allsku = ProductsBase.ProductInfoCatalog.AllSKUs; foreach (var badge in badgeList) { if (allsku.ContainsKey(badge.BadgeCode)) { var sku = allsku[badge.BadgeCode]; if (ShoppingCartProvider.CheckInventory(sku.CatalogItem, badge.Quantity, ProductsBase.CurrentWarehouse) > 0 && CatalogProvider.GetProductAvailability(sku, ProductsBase.CurrentWarehouse) == ProductAvailabilityType.Available) { cblFreeGiftlist.Items.Add( new ListItem { Selected = true, Text = String.Format(s_promotionItemDisplayFormat, badge.BadegName, badge.Quantity), Value = sku.SKU }); //divPromo.Visible = true; badgePromoList.Add(sku.CatalogItem); } } } //var myShoppingCart = ProductsBase.ShoppingCart; var promoInCart = ShoppingCart.CartItems.Select(c => c.SKU).Intersect(badgePromoList.Select(f => f.SKU)); if (promoInCart.Any()) { foreach (var x in promoInCart) { var foundItems = new List <ListItem>(); foreach (ListItem item in cblFreeGiftlist.Items) { if (item.Value == x) { foundItems.Add(item); } } foundItems.ForEach(f => cblFreeGiftlist.Items.Remove(f)); } } else { btnAddToCart.Enabled = true; // ShoppingCart.HastakenSrPromotion = false; lblFreeGift.Text = GetLocalResourceObject("lblFreeGiftResource1.Text") as string; } if (ShoppingCart.CartItems.Count >= 1) { var others = ShoppingCart.CartItems.Where(s => !s.IsPromo) .Select(c => c.SKU) .Except(APFDueProvider.GetAPFSkuList()); if (!others.Any()) { if (promoInCart.Any()) { ShoppingCart.DeleteItemsFromCart(promoInCart.ToList(), true); } } } divPromo.Visible = cblFreeGiftlist.Items.Count > 0; } } else { var itemsInBoth = ShoppingCart.CartItems .Where(x => x.IsPromo) .Select(c => c.SKU) .Intersect(badgeList.Select(b => b.BadgeCode), StringComparer.OrdinalIgnoreCase); if (itemsInBoth.Any()) { ShoppingCart.DeleteItemsFromCart(itemsInBoth.ToList(), true); } } } } promotionPanel.Update(); }
protected void Page_Load(object sender, EventArgs e) { DistributorOrderingProfile dsProfile = DistributorOrderingProfileProvider.GetProfile(DistributorID, CountryCode); string DSType = dsProfile.OrderSubType; //lblProductType.Visible = false; if (!IsPostBack) { if (ShoppingCart.OrderCategory == OrderCategoryType.ETO) { trOrderType.Visible = false; trRemainingVal.Visible = false; ShoppingCart.SelectedDSSubType = "D2"; PurchasingLimitProvider.GetPurchasingLimits(DistributorID, "ETO"); return; } else { if (ShoppingCart.SelectedDSSubType == "ETO") { ShoppingCart.SelectedDSSubType = String.Empty; } } //lblPickupLocation.Visible = ddlPickup.Visible = false; bool noConsignmentOrdersAllowed = false; if (DSType.Equals("A") || DSType.Equals("B")) { if (APFDueProvider.IsAPFDueAndNotPaid(DistributorID, Locale)) { noConsignmentOrdersAllowed = true; } } //Begin HD Ticket 406707 if (ShoppingCart.OrderSubType == "A2" || ShoppingCart.OrderSubType == "B2") { bool isAPFDue = APFDueProvider.IsAPFDueAndNotPaid(DistributorID, Locale) || APFDueProvider.IsAPFDueWithinOneYear(DistributorID, CountryCode) || APFDueProvider.IsAPFDueGreaterThanOneYear(DistributorID, CountryCode); if (!isAPFDue) { //delete APF SKU from cart ShoppingCart.DeleteItemsFromCart(APFDueProvider.GetAPFSkuList()); } } //End HD Ticket 406707 if (noConsignmentOrdersAllowed) { lbltext.Text = GetLocalResourceObject("CannotPlaceConsignmentWhileAPFDue") as string; lbltext.Visible = true; } ddl_DSSubType.Enabled = false; //ddlDelivery.Enabled = false; trRemainingVal.Visible = false; switch (DSType) { case "A": ddl_DSSubType.Items.Clear(); if (!HideEmptyListItem) { ddl_DSSubType.Items.Add(string.Empty); } if (!noConsignmentOrdersAllowed) { ddl_DSSubType.Items.Add(new ListItem("Vendita a Cliente ", "A1")); //TODOD: Resx these } ddl_DSSubType.Items.Add(new ListItem("Uso Personale", "A2")); ddl_DSSubType.Enabled = true; if (!String.IsNullOrEmpty(ShoppingCart.SelectedDSSubType)) { ddl_DSSubType.ClearSelection(); ListItem item = ddl_DSSubType.Items.FindByValue(ShoppingCart.SelectedDSSubType); if (null != item) { item.Selected = true; lblOrderTypeVal.Text = item.Text; } //lblOrderTypeVal.Text = ddl_DSSubType.Items.FindByValue(ShoppingCart.SelectedDSSubType).Text; DisplayRemainingValues(ShoppingCart.SelectedDSSubType); } break; case "B": ddl_DSSubType.Items.Clear(); if (!HideEmptyListItem) { ddl_DSSubType.Items.Add(string.Empty); } if (!noConsignmentOrdersAllowed) { ddl_DSSubType.Items.Add(new ListItem("Vendita a Cliente", "B1")); DisplayRemainingValues(ShoppingCart.SelectedDSSubType); } ddl_DSSubType.Items.Add(new ListItem("Uso Personale", "B2")); ddl_DSSubType.Enabled = true; if (!String.IsNullOrEmpty(ShoppingCart.SelectedDSSubType)) { ddl_DSSubType.ClearSelection(); ListItem item = ddl_DSSubType.Items.FindByValue(ShoppingCart.SelectedDSSubType); if (null != item) { item.Selected = true; lblOrderTypeVal.Text = item.Text; } DisplayRemainingValues(ShoppingCart.SelectedDSSubType); trRemainingVal.Visible = true; } break; case "C": case "D": case "D2": case "E": if (DSType == "D") { DSType = "D2"; } lblOrderType.Visible = false; lblOrderTypeVal.Text = "Uso Personale"; ddl_DSSubType.Visible = false; ddl_DSSubType.Items.Clear(); ddl_DSSubType.Items.Add(new ListItem(DSType, DSType)); ddl_DSSubType.SelectedIndex = 0; //ddl_DSSubType.Enabled = false; //ddl_DSSubType.Items.Add(DSType); //ddlDelivery.Enabled = true; break; } if (ddl_DSSubType.SelectedItem != null) { ShoppingCart.SelectedDSSubType = ddl_DSSubType.SelectedItem.Value; } if (DisplayStatic) { if (DSType.Equals("A") || DSType.Equals("B")) { ddl_DSSubType.Visible = false; lblOrderTypeVal.Visible = true; } else if (DSType.Equals("D") || DSType.Equals("D2") || DSType.Equals("E")) { DisplayRemainingValues(DSType); } } else { if (DSType.Equals("A") || DSType.Equals("B")) { ddl_DSSubType.Visible = true; lblOrderTypeVal.Visible = false; } else if (DSType.Equals("D") || DSType.Equals("D2") || DSType.Equals("E")) { DisplayRemainingValues(DSType); } } if (this.FOPEnabled) { var limits = PurchasingLimitProvider.GetPurchasingLimits(DistributorID, DSType); if (limits != null && limits.LimitsRestrictionType == LimitsRestrictionType.FOP) { DisplayRemainingValues(DSType); } } } }
/// <summary> /// Validates if the promo should be in cart. /// </summary> /// <param name="shoppingCart">The shopping cart.</param> /// <param name="cart">The MyHL shopping cart.</param> /// <param name="result">The promo rule result.</param> /// <returns></returns> private ShoppingCartRuleResult CheckPromoInCart(ShoppingCart_V02 shoppingCart, MyHLShoppingCart cart, ShoppingCartRuleResult result) { // Check the order type var session = SessionInfo.GetSessionInfo(cart.DistributorID, cart.Locale); if (session.IsEventTicketMode) { return(result); } // Check if promo sku should be in cart var promoInCart = cart.CartItems != null && cart.CartItems.Any(i => i.SKU.Equals(PromoSKU)); var apfSkus = APFDueProvider.GetAPFSkuList(); var applyForPromo = cart.CartItems != null && cart.CartItems.Any( i => !apfSkus.Contains(i.SKU) && !i.SKU.Equals(HLConfigManager.Configurations.DOConfiguration.HFFHerbalifeSku) && !i.SKU.Equals(PromoSKU)); // Check if APF standalone order if (APFDueProvider.hasOnlyAPFSku(cart.CartItems, cart.Locale)) { return(result); } // Check HFF standalone if (ShoppingCartProvider.IsStandaloneHFF(cart.ShoppingCartItems)) { return(result); } if (!applyForPromo) { if (promoInCart) { cart.DeleteItemsFromCart(new List <string> { PromoSKU }, true); } // Nothing to do result.Result = RulesResult.Success; cart.RuleResults.Add(result); return(result); } //Check promo sku catalog info var allSkus = CatalogProvider.GetAllSKU(Locale); if (!allSkus.Keys.Contains(PromoSKU)) { if (Environment.MachineName.IndexOf("PROD", StringComparison.Ordinal) < 0) { var country = new RegionInfo(new CultureInfo(Locale, false).LCID); string message = "NoPromoSku"; var globalResourceObject = HttpContext.GetGlobalResourceObject(string.Format("{0}_Rules", HLConfigManager.Platform), "NoPromoSku"); if (globalResourceObject != null) { message = string.Format(globalResourceObject.ToString(), country.DisplayName, PromoSKU); } result.Result = RulesResult.Feedback; result.Messages.Add(message); cart.RuleResults.Add(result); return(result); } return(result); } // Adding promo sku if possible var isRuleTime = IsRuleTime(); if (!promoInCart && isRuleTime && !string.IsNullOrEmpty(cart.DeliveryInfo.WarehouseCode)) { WarehouseInventory warehouseInventory; var catItemPromo = CatalogProvider.GetCatalogItem(PromoSKU, Country); if (catItemPromo.InventoryList.TryGetValue(cart.DeliveryInfo.WarehouseCode, out warehouseInventory)) { if (warehouseInventory != null) { var warehouseInventory01 = warehouseInventory as WarehouseInventory_V01; if (warehouseInventory01 != null && warehouseInventory01.QuantityAvailable > 0) { cart.AddItemsToCart( new List <ShoppingCartItem_V01>(new[] { new ShoppingCartItem_V01(0, PromoSKU, 1, DateTime.Now) }), true); result.Result = RulesResult.Success; cart.RuleResults.Add(result); } } } } else if (promoInCart && !isRuleTime) { // Remove the promo sku cart.DeleteItemsFromCart(new List <string> { PromoSKU }, true); result.Result = RulesResult.Success; cart.RuleResults.Add(result); } return(result); }