public override bool GetDistributorShippingInfoForHMS(MyHLShoppingCart shoppingCart, Shipment shippment) { //BE: Street 1 and House Number will be saved and sent to fusion as Street1 + <Space> + House Number in Street1 shippment.Address.Line1 = string.Format("{0} {1}", shippment.Address.Line1.Trim(), shippment.Address.Line2.Trim()); shippment.Address.Line2 = string.Empty; return(true); }
public void SKU0106_OverLimit_TestMethod1() { var cartItems = new ShoppingCartItemList(); cartItems.Add(new ShoppingCartItem_V01 { SKU = "0120", Quantity = 1 }); cartItems.Add(new ShoppingCartItem_V01 { SKU = "0106", Quantity = 6 }); //NFO var cartItemsBeingAdded = new ShoppingCartItemList(); cartItemsBeingAdded.Add(new ShoppingCartItem_V01 { SKU = "0106", Quantity = 4 }); MyHLShoppingCart cart = MyHLShoppingCartGenerator.GetBasicShoppingCart("staff", "ja-JP", "XX", "XX", cartItems, OrderCategoryType.RSO); cart.ItemsBeingAdded = cartItemsBeingAdded; MyHerbalife3.Ordering.Rules.PurchaseRestriction.JP.PurchaseRestrictionRules rules = new MyHerbalife3.Ordering.Rules.PurchaseRestriction.JP.PurchaseRestrictionRules(); rules.HandleCartItemsBeingAdded(cart, new ShoppingCartRuleResult(), MockPurchaseRestrictionInfo()); }
public override string GetShippingInstructionsForDS(MyHLShoppingCart shoppingCart, string distributorID, string locale) { ShippingInfo shippingInfo = shoppingCart.DeliveryInfo; string instruction = string.IsNullOrEmpty(shoppingCart.DeliveryInfo.Instruction) ? string.Empty : shoppingCart.DeliveryInfo.Instruction; if (shippingInfo != null) { if (shippingInfo.Option == DeliveryOptionType.PickupFromCourier) { string countryCode = locale.Substring(3, 2); List <PickupLocationPreference_V01> pickupLocationPreference = GetPickupLocationsPreferences(distributorID, countryCode); if (pickupLocationPreference != null && pickupLocationPreference.Count > 0) { var pickupLocation = pickupLocationPreference.Find(p => p.ID == shippingInfo.Id); // PickupFromCourier return instuction=RecipientNam,Phone if (shoppingCart.DeliveryInfo != null && pickupLocation != null && pickupLocation.PickupLocationID > 0) { return(instruction = string.Format("{0},{1} {2}", shoppingCart.DeliveryInfo.Address.Recipient, shoppingCart.DeliveryInfo.Address.Phone, pickupLocation.PickupLocationID.ToString())); } } return(string.Empty); } } return(base.GetShippingInstructionsForDS(shoppingCart, distributorID, locale)); }
/// <summary> /// The should select this cross sell. /// </summary> /// <param name="cs"> /// The cs. /// </param> /// <param name="shoppingCart"> /// The shopping cart. /// </param> /// <param name="lastSeenProd"> /// The last seen prod. /// </param> /// <param name="lastSeenCrossSell"> /// The last seen cross sell. /// </param> /// <returns> /// The should select this cross sell. /// </returns> public static bool ShouldSelectThisCrossSell( ProductInfo_V02 cs, MyHLShoppingCart shoppingCart, CrossSellInfo lastSeenProd, CrossSellInfo lastSeenCrossSell ) { // if it is in shopping cart, do not pick if (ifInShoppingCart(shoppingCart, cs)) { return(false); } if (lastSeenProd != null && cs.ID == lastSeenProd.Product.ID) { return(false); } if (lastSeenCrossSell != null && cs.ID == lastSeenCrossSell.Product.ID) { return(false); } return(true); }
public void Page_Load(object sender, EventArgs e) { (Page.Master as OrderingMaster).EventBus.RegisterObject(this); _cart = (Page as ProductsBase).ShoppingCart; _APFExempted = APFDueProvider.IsAPFExemptOn200VP(DistributorOrderingProfile, _cart.VolumeInCart); Visible = APFDueProvider.ShouldShowAPFModule(DistributorID); if (DistributorOrderingProfile.IsPC || SessionInfo.IsReplacedPcOrder || ShoppingCart.OrderCategory == OrderCategoryType.ETO) { Visible = false; return; } _APFStatus = DistributorOrderingProfile.CNAPFStatus; if (_APFStatus == 2 && Visible) { pnlAPFIsDueWithinThreeMonth.Visible = false; pnlAPFPaid.Visible = false; ReadFromPage(); GracePeriodAPFDisplay(); } else //Legacy handling { Visible = APFDueProvider.ShouldShowAPFModule(DistributorID); if (Visible) { pnlAPFIsDueWithinThreeMonth.Visible = false; pnlAPFPaid.Visible = false; ReadFromPage(); DisplayData(); } } }
/// <summary> /// Gets the shipment information to import into HMS. /// </summary> /// <param name="shoppingCart">The shopping cart.</param> /// <param name="shippment">The order shipment.</param> /// <returns></returns> public override bool GetDistributorShippingInfoForHMS(MyHLShoppingCart shoppingCart, Shipment shippment) { if (shoppingCart != null && shoppingCart.DeliveryInfo != null) { string freightCodeInCart = shoppingCart.DeliveryInfo.FreightCode; var session = SessionInfo.GetSessionInfo(shoppingCart.DistributorID, shoppingCart.Locale); if (session.IsEventTicketMode) { shippment.ShippingMethodID = shoppingCart.FreightCode = shoppingCart.DeliveryInfo.FreightCode = HLConfigManager.Configurations.CheckoutConfiguration.EventTicketFreightCode; } else if (APFDueProvider.hasOnlyAPFSku(shoppingCart.CartItems, shoppingCart.Locale)) { shippment.ShippingMethodID = shoppingCart.FreightCode = shoppingCart.DeliveryInfo.FreightCode = HLConfigManager.Configurations.APFConfiguration.APFFreightCode; } else { string defaultFreight = HLConfigManager.Configurations.ShoppingCartConfiguration.DefaultFreightCode; shippment.WarehouseCode = shoppingCart.DeliveryInfo.WarehouseCode = HLConfigManager.Configurations.ShoppingCartConfiguration.DefaultWarehouse; if (shoppingCart.DeliveryInfo.Option == DeliveryOptionType.Shipping) { shippment.ShippingMethodID = shoppingCart.FreightCode = shoppingCart.DeliveryInfo.FreightCode = defaultFreight; } else { shippment.ShippingMethodID = shoppingCart.FreightCode = shoppingCart.DeliveryInfo.FreightCode = "PU"; } } if (!freightCodeInCart.Equals(shoppingCart.FreightCode)) { shoppingCart.Calculate(); ShoppingCartProvider.UpdateShoppingCart(shoppingCart); } } return(true); }
private ShoppingCartRuleResult reportError(MyHLShoppingCart cart, ShoppingCartItem_V01 item, ShoppingCartRuleResult Result) { Result.Result = RulesResult.Failure; if (cart.CartItems.Exists(i => i.SKU == item.SKU)) { ///The quantity of the item SKU:{0} can not be increased by {1} because it exceeds your Purchasing Limit. Result.Messages.Add( string.Format( HttpContext.GetGlobalResourceObject( string.Format("{0}_Rules", HLConfigManager.Platform), "DiscountedRetailExceedsByIncreasingQuantity").ToString(), item.SKU, item.Quantity)); } else { ///Item SKU:{0} has not been added to the cart since by adding that into the cart, you exceeded your Purchasing Limit. Result.Messages.Add( string.Format( HttpContext.GetGlobalResourceObject( string.Format("{0}_Rules", HLConfigManager.Platform), "DiscountedRetailExceeds").ToString(), item.SKU)); } cart.RuleResults.Add(Result); return(Result); }
/// <summary> /// Gets the shipment information to import into HMS. /// </summary> /// <param name="shoppingCart">The shopping cart.</param> /// <param name="shippment">The order shipment.</param> /// <returns></returns> public override bool GetDistributorShippingInfoForHMS(MyHLShoppingCart shoppingCart, MyHerbalife3.Ordering.ServiceProvider.SubmitOrderBTSvc.Shipment shippment) { if (shoppingCart != null && shoppingCart.DeliveryInfo != null) { string freightCodeInCart = shoppingCart.DeliveryInfo.FreightCode; var session = SessionInfo.GetSessionInfo(shoppingCart.DistributorID, shoppingCart.Locale); if (session.IsEventTicketMode || APFDueProvider.hasOnlyAPFSku(shoppingCart.CartItems, shoppingCart.Locale)) { return(true); } if (shoppingCart.FreightCode == "NOF") { shippment.ShippingMethodID = shoppingCart.FreightCode = shoppingCart.DeliveryInfo.FreightCode = shoppingCart.DeliveryInfo.Option == DeliveryOptionType.Shipping ? "UAF" : "PU"; } if (shoppingCart.DeliveryInfo.Option == DeliveryOptionType.Shipping) { shoppingCart.DeliveryInfo.WarehouseCode = HLConfigManager.Configurations.ShoppingCartConfiguration.DefaultWarehouse; } if (!freightCodeInCart.Equals(shoppingCart.FreightCode)) { shoppingCart.Calculate(); ShoppingCartProvider.UpdateShoppingCart(shoppingCart); } } return(true); }
private void ReadFromData() { DistributorOrderingProfile distributorOrderingProfile = DistributorOrderingProfileProvider.GetProfile(DistributorID, CountryCode); _distributorId = DistributorID; _apfDueDate = distributorOrderingProfile.ApfDueDate; if (_testing) { APFDueProvider.UpdateAPFDuePaid(_distributorId, _apfDueDate); } _apfSku = APFDueProvider.GetAPFSku(); _cart = (Page as ProductsBase).ShoppingCart; _apfIsDue = APFDueProvider.IsAPFDueAndNotPaid(_distributorId, HLConfigManager.Configurations.Locale); _apfDueWithinOneYear = APFDueProvider.IsAPFDueWithinOneYear(_distributorId, CountryCode); _apfDueGreaterThanOneYear = APFDueProvider.IsAPFDueGreaterThanOneYear(_distributorId, CountryCode); if (_apfIsDue) { _apfsDue = APFDueProvider.APFQuantityDue(_distributorId, HLConfigManager.Configurations.Locale); } List <ShoppingCartItem_V01> item = (from c in _cart.CartItems where c.SKU == _apfSku select c).ToList(); _apfsInCart = 0; if (item.Count > 0) { _apfsInCart = item[0].Quantity; } }
/// <summary> /// Get the shipping instructions. /// </summary> /// <param name="shoppingCart">The shopping cart.</param> /// <param name="distributorID">The distributor Id.</param> /// <param name="locale">The locale.</param> /// <returns></returns> public override string GetShippingInstructionsForDS(MyHLShoppingCart shoppingCart, string distributorID, string locale) { string instruction = shoppingCart.DeliveryInfo == null || string.IsNullOrEmpty(shoppingCart.DeliveryInfo.Instruction) ? string.Empty : shoppingCart.DeliveryInfo.Instruction; if (shoppingCart.DeliveryInfo != null && shoppingCart.DeliveryInfo.Option == DeliveryOptionType.Pickup && shoppingCart.DeliveryInfo.PickupDate.HasValue) { instruction = string.Format("{0}", shoppingCart.DeliveryInfo.PickupDate.Value.ToString("d", CultureInfo.CurrentCulture)); } if (!string.IsNullOrEmpty(shoppingCart.InvoiceOption) && shoppingCart.InvoiceOption == InvoiceHandlingType.SendToDistributor.ToString()) { const string invoiceOption = "Док-ти надіслати на поштову адресу Незалежного Партнера"; instruction = string.Format("{0}{1}", string.IsNullOrEmpty(instruction) ? instruction : string.Format("{0} ", instruction), invoiceOption); } if (shoppingCart.DeliveryInfo != null && shoppingCart.DeliveryInfo.Option == DeliveryOptionType.PickupFromCourier) { if (!string.IsNullOrEmpty(shoppingCart.InvoiceOption) && shoppingCart.InvoiceOption == InvoiceHandlingType.SendToDistributor.ToString()) { instruction = "Доставка до Відділення МІСТ, Док.поштою НП"; } else { instruction = "Доставка до Відділення МІСТ"; } } return(instruction.Trim()); }
/// <summary> /// called before pricing /// </summary> /// <param name="shoppingCart"></param> /// <param name="address"></param> public override void GetDistributorShippingInfoForHMS(MyHLShoppingCart shoppingCart, MyHerbalife3.Ordering.ServiceProvider.OrderSvc.ShippingInfo_V01 address) { if (shoppingCart != null && shoppingCart.DeliveryInfo != null) { string freightCodeInCart = shoppingCart.DeliveryInfo.FreightCode; var session = SessionInfo.GetSessionInfo(shoppingCart.DistributorID, shoppingCart.Locale); if (session.IsEventTicketMode || APFDueProvider.hasOnlyAPFSku(shoppingCart.CartItems, shoppingCart.Locale)) { shoppingCart.FreightCode = shoppingCart.DeliveryInfo.FreightCode = "NOF"; } else { if (shoppingCart.FreightCode == "NOF") { shoppingCart.FreightCode = shoppingCart.DeliveryInfo.FreightCode = shoppingCart.DeliveryInfo.Option == DeliveryOptionType.Shipping ? "UAF" : "PU"; } if (shoppingCart.DeliveryInfo.Option == DeliveryOptionType.Shipping) { shoppingCart.DeliveryInfo.WarehouseCode = HLConfigManager.Configurations.ShoppingCartConfiguration.DefaultWarehouse; } } if (!freightCodeInCart.Equals(shoppingCart.FreightCode)) { ShoppingCartProvider.UpdateShoppingCart(shoppingCart); } } }
public static bool ShouldHideOrderQuickView(MyHLShoppingCart cart) { if (cart == null) { HL.Common.Logging.LoggerHelper.Error("APFDueProvider.ShouldHideOrderQuickView() : Null MyHLShoppingCart. Check that service can return a valid cart"); } var hide = false; if (cart != null && cart.OrderCategory != OrderCategoryType.ETO) //We don't hassle them for ETOs { if (HLConfigManager.Configurations.APFConfiguration.StandaloneAPFOnlyAllowed) { if (!HLConfigManager.Configurations.APFConfiguration.ShowOrderQuickViewForStandaloneAPF) { if (IsAPFSkuPresent(cart.CartItems) || IsAPFDueAndNotPaid(cart.DistributorID, cart.Locale)) { hide = true; } } } } return(hide); }
public void PerformDiscountRules(ShoppingCart_V02 cart, Order_V01 order, string locale) { MyHLShoppingCart shoppingCart = cart as MyHLShoppingCart; var member = (MembershipUser <DistributorProfileModel>)Membership.GetUser(); decimal CartVolume = 0.0M; foreach (ShoppingCartItem_V01 CartItem in shoppingCart.CartItems) { var item = CatalogProvider.GetCatalogItem(CartItem.SKU, shoppingCart.CountryCode); if (item != null) { CartVolume += (item.VolumePoints) * CartItem.Quantity; } } List <string> codes = new List <string>(CountryType.VE.HmsCountryCodes); if (order != null && shoppingCart != null && CartVolume >= 500 && member.Value.TypeCode != "SP" && codes.Contains(member.Value.ProcessingCountryCode)) { order.UseSlidingScale = false; order.DiscountPercentage = 42; } }
public override string GetShippingInstructionsForDS(MyHLShoppingCart shoppingCart, string distributorID, string locale) { ShippingInfo currentShippingInfo = shoppingCart.DeliveryInfo; // Checking for null, avoiding an exception. if (shoppingCart.InvoiceOption == null) { shoppingCart.InvoiceOption = string.Empty; } var invoiceOption = HttpContext.GetGlobalResourceObject("InvoiceOptions", shoppingCart.InvoiceOption.Trim(), CultureInfo.CurrentCulture); if (invoiceOption == null) { invoiceOption = shoppingCart.InvoiceOption.Trim(); } string instruction = string.Empty; if (shoppingCart.DeliveryInfo.Option == DeliveryOptionType.Pickup) { return(instruction = string.Format("{0},{1},{2}", shoppingCart.DeliveryInfo.Address.Recipient, shoppingCart.DeliveryInfo.Address.Phone, invoiceOption)); } else { instruction = currentShippingInfo == null ? invoiceOption as string : string.Format("{0} {1}", currentShippingInfo.Instruction, invoiceOption); } return(instruction.Trim()); }
public override ShippingInfo GetShippingInfoFromID(string distributorID, string locale, DeliveryOptionType type, int deliveryOptionID, int shippingAddressID) { ShippingInfo shippingInfo = base.GetShippingInfoFromID(distributorID, locale, type, deliveryOptionID, shippingAddressID); if (shippingInfo != null && shippingInfo.Address != null && type == DeliveryOptionType.Shipping) { List <DeliveryOption> shippingOptions = GetDeliveryOptionsListForShipping("BO", "es-BO", shippingInfo.Address); if (shippingOptions != null) { var shippingOption = shippingOptions.FirstOrDefault(); if (shippingOption != null && shippingInfo.FreightCode != shippingOption.FreightCode) { shippingInfo.FreightCode = shippingOption.FreightCode; shippingInfo.WarehouseCode = shippingOption.WarehouseCode; MyHLShoppingCart myShoppingCart = ShoppingCartProvider.GetShoppingCart(distributorID, locale); if (myShoppingCart != null) { if (myShoppingCart.ShippingAddressID != shippingInfo.Address.ID || myShoppingCart.FreightCode != shippingOption.FreightCode) { myShoppingCart.DeliveryInfo = shippingInfo; myShoppingCart.FreightCode = shippingOption.FreightCode; myShoppingCart.ShippingAddressID = shippingInfo.Address.ID; ShoppingCartProvider.UpdateShoppingCart(myShoppingCart); } } } } } return(shippingInfo); }
private void CleanupCart(MyHLShoppingCart cart) { if (PurchasingLimitProvider.RequirePurchasingLimits(cart.DistributorID, cart.CountryCode)) { PurchasingLimitProvider.ReconcileAfterPurchase(cart, cart.DistributorID, Country); } if (null != HttpContext.Current) { var currentSession = SessionInfo.GetSessionInfo(cart.DistributorID, Locale); if (currentSession != null) { if (!String.IsNullOrEmpty(currentSession.OrderNumber)) { currentSession.OrderNumber = String.Empty; currentSession.OrderMonthShortString = string.Empty; currentSession.OrderMonthString = string.Empty; currentSession.ShippingMethodNameMX = String.Empty; currentSession.ShippingMethodNameUSCA = String.Empty; currentSession.ShoppingCart.CustomerOrderDetail = null; // currentSession.CustomerPaymentSettlementApproved = false; Commented out for merge. Need to investigate currentSession.CustomerOrderNumber = String.Empty; currentSession.CustomerAddressID = 0; } } //Clear the order month session... HttpContext.Current.Session["OrderMonthDataSessionKey"] = null; SessionInfo.SetSessionInfo(cart.DistributorID, Locale, currentSession); } ShoppingCartProvider.UpdateInventory(cart, Country, Locale, true); }
/// <summary> /// GetDistributorShippingInfoForHMS /// </summary> /// <param name="shoppingCart"></param> /// <param name="address"></param> public override void GetDistributorShippingInfoForHMS(MyHLShoppingCart shoppingCart, ShippingInfo_V01 address) { if (shoppingCart != null && shoppingCart.DeliveryInfo != null) { string freightCodeInCart = shoppingCart.DeliveryInfo.FreightCode; var session = SessionInfo.GetSessionInfo(shoppingCart.DistributorID, shoppingCart.Locale); if (session.IsEventTicketMode) { shoppingCart.FreightCode = shoppingCart.DeliveryInfo.FreightCode = HLConfigManager.Configurations.CheckoutConfiguration.EventTicketFreightCode; } else if (APFDueProvider.hasOnlyAPFSku(shoppingCart.CartItems, shoppingCart.Locale)) { shoppingCart.FreightCode = shoppingCart.DeliveryInfo.FreightCode = HLConfigManager.Configurations.APFConfiguration.APFFreightCode; } else { string defaultFreight = HLConfigManager.Configurations.ShoppingCartConfiguration.DefaultFreightCode; if (shoppingCart.DeliveryInfo.Option == DeliveryOptionType.Shipping) { shoppingCart.FreightCode = shoppingCart.DeliveryInfo.FreightCode = defaultFreight; } else { shoppingCart.FreightCode = shoppingCart.DeliveryInfo.FreightCode = "PU"; } } if (!freightCodeInCart.Equals(shoppingCart.FreightCode)) { ShoppingCartProvider.UpdateShoppingCart(shoppingCart); } } }
public static Order CreateOrderObject(MyHLShoppingCart shoppingCart) { var order = HLConfigManager.Configurations.DOConfiguration.IsChina ? China.OrderProvider.CreateOrderObject( (from s in shoppingCart.ShoppingCartItems select(DistributorShoppingCartItem) s) .ToList <DistributorShoppingCartItem>()) as Order : CreateOrderObject( (from s in shoppingCart.ShoppingCartItems select(ShoppingCartItem_V01) s) .ToList <ShoppingCartItem_V01>()) as Order_V01; Order_V01 orderV01 = order as Order_V01; if (PurchasingLimitProvider.RequirePurchasingLimits(shoppingCart.DistributorID, shoppingCart.CountryCode)) { orderV01.PurchasingLimits = PurchasingLimitProvider.GetCurrentPurchasingLimits(shoppingCart.DistributorID); } if (HLConfigManager.Configurations.DOConfiguration.UsesTaxRules) { if (null != order) { if (null != shoppingCart.DeliveryInfo) { orderV01.Shipment = GetShippingInfoFromCart(shoppingCart); } HLRulesManager.Manager.PerformTaxationRules(orderV01, shoppingCart.Locale); } } return(order); }
/// <summary> /// Gets the order. /// </summary> /// <param name="locale">The locale.</param> /// <param name="distributorID">The distributor ID.</param> /// <param name="shoppingCart">The shopping cart.</param> /// <returns></returns> public static Order_V01 GetOrder(string locale, string distributorID, MyHLShoppingCart shoppingCart) { var order = (Order_V01)OrderCreationHelper.CreateOrderObject(shoppingCart); OrderCreationHelper.FillOrderInfo(order, shoppingCart); return(order); }
public static Order FillOrderInfo(Order _order, MyHLShoppingCart shoppingCart) { Order_V01 order = _order as Order_V01; order.DistributorID = shoppingCart.DistributorID; order.Shipment = GetShippingInfoFromCart(shoppingCart); order.InputMethod = InputMethodType.Internet; var recvdDate = DateUtils.GetCurrentLocalTime(shoppingCart.Locale.Substring(3, 2)); order.ReceivedDate = recvdDate; // TODO : Order CATEGORY order.OrderCategory = (ServiceProvider.OrderSvc.OrderCategoryType)Enum.Parse(typeof(ServiceProvider.OrderSvc.OrderCategoryType), shoppingCart.OrderCategory.ToString()); //OrderCategoryType.RSO; if (order.OrderCategory == ServiceProvider.OrderSvc.OrderCategoryType.ETO) { if (!String.IsNullOrEmpty(HLConfigManager.Configurations.CheckoutConfiguration.EventTicketOrderType)) { order.OrderCategory = (ServiceProvider.OrderSvc.OrderCategoryType) Enum.Parse(typeof(ServiceProvider.OrderSvc.OrderCategoryType), HLConfigManager.Configurations.CheckoutConfiguration.EventTicketOrderType); } } var orderMonth = new OrderMonth(shoppingCart.CountryCode); order.OrderMonth = orderMonth.OrderMonthShortString; //order.OrderMonth = DateTime.Now.ToString("yyMM"); order.UseSlidingScale = HLConfigManager.Configurations.CheckoutConfiguration.UseSlidingScale; order.CountryOfProcessing = shoppingCart.CountryCode; DistributorOrderingProfile distributorOrderingProfile = DistributorOrderingProfileProvider.GetProfile(shoppingCart.DistributorID, shoppingCart.CountryCode); if (null != distributorOrderingProfile) { //order.DiscountPercentage = order.UseSlidingScale && distributorOrderingProfile.StaticDiscount < 50 // ? 0 // : distributorOrderingProfile.StaticDiscount; order.DiscountPercentage = distributorOrderingProfile.StaticDiscount; // always pass profile discount } if (HLConfigManager.Configurations.DOConfiguration.UsesDiscountRules) { HLRulesManager.Manager.PerformDiscountRules(shoppingCart, order, shoppingCart.Locale, ShoppingCartRuleReason.CartBeingCalculated); } if (HLConfigManager.Configurations.DOConfiguration.usesOrderManagementRules) { HLRulesManager.Manager.PerformOrderManagementRules(shoppingCart, order, shoppingCart.Locale, OrderManagementRuleReason.OrderFilled); } // some countries, like IT, need OrderSubType for correct Fusion pricing. // Added for User Story 226150 if (HLConfigManager.Configurations.DOConfiguration.SaveDSSubType) { order.OrderSubType = shoppingCart.SelectedDSSubType; } return(order); }
/// <summary> /// Gets the shipping instructions for the DS. /// </summary> /// <param name="shoppingCart">The shopping cart.</param> /// <param name="distributorID">Distributor ID.</param> /// <param name="locale">Locale.</param> /// <returns>The shipping instructions.</returns> public override string GetShippingInstructionsForDS(MyHLShoppingCart shoppingCart, string distributorID, string locale) { string shippingInstructions = string.Empty; if (!string.IsNullOrEmpty(shoppingCart.InvoiceOption)) { if (shoppingCart.InvoiceOption.Trim() == "SendToDistributor") { shippingInstructions = "Factura catre DS"; } } ShippingInfo currentShippingInfo = shoppingCart.DeliveryInfo; if (currentShippingInfo != null) { if (currentShippingInfo.Option == DeliveryOptionType.Pickup) { shippingInstructions = (shippingInstructions.Length > 0) ? string.Format("{0} {1}", shippingInstructions, currentShippingInfo.Instruction) : currentShippingInfo.Instruction; } } var skus = from i in shoppingCart.CartItems from s in skuForInstructions where i.SKU == s select i.SKU; if (skus.Count() > 0) { string instrBySKU = "Pretul pungilor include si Ecotaxa de 0.1 lei/buc"; shippingInstructions = (shippingInstructions.Length > 0) ? string.Format("{0} {1}", shippingInstructions, instrBySKU) : instrBySKU; } return(shippingInstructions); }
public static ShippingInfo_V01 GetShippingInfoFromCart(MyHLShoppingCart cart) { var shipping = new ShippingInfo_V01(); var deliveryInfo = cart.DeliveryInfo; if (deliveryInfo == null) { shipping.FreightVariant = HLConfigManager.Configurations.DOConfiguration.IsChina ? "EXP" : ShippingProvider.GetShippingProvider(cart.CountryCode).GetFreightVariant(null); shipping.ShippingMethodID = HLConfigManager.Configurations.ShoppingCartConfiguration.DefaultFreightCode; shipping.WarehouseCode = HLConfigManager.Configurations.ShoppingCartConfiguration.DefaultWarehouse; } else { shipping.FreightVariant = HLConfigManager.Configurations.DOConfiguration.IsChina ? deliveryInfo.AddressType : deliveryInfo.FreightVariant; shipping.ShippingMethodID = deliveryInfo.FreightCode; shipping.WarehouseCode = deliveryInfo.WarehouseCode; } shipping.Address = addressNotValid(deliveryInfo) ? CreateDefaultAddress() : ObjectMappingHelper.Instance.GetToOrder(deliveryInfo.Address.Address); var provider = ShippingProvider.GetShippingProvider(null); if (provider != null) { provider.GetDistributorShippingInfoForHMS(cart, shipping); } return(shipping); }
/// <summary> /// The select cross sell from previous display or crss sell list. /// </summary> /// <param name="crossSellList"> /// The cross sell list. /// </param> /// <param name="lastSeenCrossSell"> /// The last seen cross sell. /// </param> /// <returns> /// </returns> public static CrossSellInfo SelectCrossSellFromPreviousDisplayOrCrssSellList(MyHLShoppingCart shoppingCart, List <CrossSellInfo> crossSellList, CrossSellInfo lastSeenCrossSell, Dictionary <string, SKU_V01> allSKUs) { CrossSellInfo candidate = null; if (lastSeenCrossSell != null && lastSeenCrossSell.Product != null) { if (!ifInShoppingCart(shoppingCart, lastSeenCrossSell.Product) && !IfOutOfStock(lastSeenCrossSell.Product, allSKUs)) { return(candidate = lastSeenCrossSell); } } if (crossSellList != null && crossSellList.Count > 0) { //return candidate = crossSellList.First(); foreach (CrossSellInfo cs in crossSellList) { if (!ifInShoppingCart(shoppingCart, cs.Product) && !IfOutOfStock(cs.Product, allSKUs)) { return(candidate = cs); } } } return(candidate); }
private void BindTotals() { var lstShoppingCartItems = (Page as ProductsBase).ShoppingCart.ShoppingCartItems; _shoppingCart = (Page as ProductsBase).ShoppingCart; try { if (lstShoppingCartItems.Count > 0 && _shoppingCart.Totals != null) { lblDiscountRate.Text = HLRulesManager.Manager.PerformDiscountRangeRules(_shoppingCart, Locale, ProductsBase .DistributorDiscount); divDiscountRate.Visible = !string.IsNullOrEmpty(lblDiscountRate.Text); lblOrderMonthVolume.Text = (Page as ProductsBase).CurrentMonthVolume; lblVolumePoints.Text = (_shoppingCart.Totals as OrderTotals_V01).VolumePoints.ToString("N2"); } else { DisplayEmptyTotals(); } } catch (Exception ex) { //Log Exception LoggerHelper.Error("Exception while displaying totals - " + ex); DisplayEmptyTotals(); } }
public static decimal TotalsExcludeAPF(MyHLShoppingCart cart, string countryCode) { if (APFDueProvider.IsAPFSkuPresent(cart.CartItems)) { var calcTheseItems = new List <ShoppingCartItem_V01>(); calcTheseItems.AddRange(from i in cart.CartItems where !APFDueProvider.IsAPFSku(i.SKU) select new ShoppingCartItem_V01(i.ID, i.SKU, i.Quantity, i.Updated, i.MinQuantity)); // remove A and L type var allItems = CatalogProvider.GetCatalogItems( (from s in calcTheseItems where s.SKU != null select s.SKU).ToList(), countryCode); if (null != allItems && allItems.Count > 0) { var skuExcluded = (from c in allItems.Values where (c as CatalogItem_V01).ProductType != ServiceProvider.CatalogSvc.ProductType.Product select c.SKU); calcTheseItems.RemoveAll(s => skuExcluded.Contains(s.SKU)); } var totals = cart.Calculate(calcTheseItems); return(totals != null ? (totals as OrderTotals_V01).AmountDue : decimal.Zero); } return(cart.Totals != null ? (cart.Totals as OrderTotals_V01).AmountDue : decimal.Zero); }
private ShoppingCartRuleResult PerformRules(ShoppingCart_V02 cart, ShoppingCartRuleReason reason, ShoppingCartRuleResult Result) { if (reason == ShoppingCartRuleReason.CartRetrieved) { try { if (CanPurchase(cart.DistributorID, Country)) { MyHLShoppingCart myShoppingCart = ShoppingCartProvider.GetShoppingCart(cart.DistributorID, cart.Locale, true); if (myShoppingCart != null && myShoppingCart.DeliveryInfo != null && myShoppingCart.DeliveryInfo.Option == ServiceProvider.ShippingSvc.DeliveryOptionType.Shipping) { if (myShoppingCart.VolumeInCart > 250M) { myShoppingCart.DeliveryInfo.FreightCode = myShoppingCart.FreightCode = "NOF"; } else { myShoppingCart.DeliveryInfo.FreightCode = myShoppingCart.FreightCode = "MCF"; } //ShoppingCartProvider.UpdateShoppingCart(myShoppingCart); } } } catch (Exception ex) { LoggerHelper.Error(string.Format("Error while performing Add to Cart Rule for Macau distributor: {0}, Cart Id:{1}, \r\n{2}", cart.DistributorID, cart.ShoppingCartID, ex.ToString())); } } return(Result); }
public void ExceedGroupLimitAndIndivualLimit_TestMethod() { var cartItems = new ShoppingCartItemList(); cartItems.Add(new ShoppingCartItem_V01 { SKU = "0120", Quantity = 9 }); var cartItemsBeingAdded = new ShoppingCartItemList(); cartItemsBeingAdded.Add(new ShoppingCartItem_V01 { SKU = "0120", Quantity = 1 }); // FO cartItemsBeingAdded.Add(new ShoppingCartItem_V01 { SKU = "0118", Quantity = 91 }); // FO cartItemsBeingAdded.Add(new ShoppingCartItem_V01 { SKU = "1158", Quantity = 11 }); // NFO MyHLShoppingCart cart = MyHLShoppingCartGenerator.GetBasicShoppingCart("staff", "ja-JP", "30", "SAG", cartItems, OrderCategoryType.RSO); cart.ItemsBeingAdded = cartItemsBeingAdded; MyHerbalife3.Ordering.Rules.PurchaseRestriction.JP.PurchaseRestrictionRules rules = new MyHerbalife3.Ordering.Rules.PurchaseRestriction.JP.PurchaseRestrictionRules(); rules.HandleCartItemsBeingAdded(cart, new ShoppingCartRuleResult(), MockPurchaseRestrictionInfo()); }
/// <summary> /// Gets the shipment information to import into HMS. /// </summary> /// <param name="shoppingCart">The shopping cart.</param> /// <param name="shippment">The order shipment.</param> /// <returns></returns> public override bool GetDistributorShippingInfoForHMS(MyHLShoppingCart shoppingCart, Shipment shippment) { var session = SessionInfo.GetSessionInfo(shoppingCart.DistributorID, shoppingCart.Locale); if (session.IsEventTicketMode) { return(true); } if (APFDueProvider.hasOnlyAPFSku(shoppingCart.CartItems, shoppingCart.Locale)) { return(true); } if (shoppingCart.DeliveryInfo != null && shoppingCart.DeliveryInfo.Option == DeliveryOptionType.Shipping && !shoppingCart.DeliveryInfo.FreightCode.Equals(HLConfigManager.Configurations.ShoppingCartConfiguration.DefaultFreightCode)) { shoppingCart.DeliveryInfo.FreightCode = HLConfigManager.Configurations.ShoppingCartConfiguration.DefaultFreightCode; shoppingCart.DeliveryInfo.WarehouseCode = HLConfigManager.Configurations.ShoppingCartConfiguration.DefaultWarehouse; shippment.ShippingMethodID = shoppingCart.DeliveryInfo.FreightCode; shippment.WarehouseCode = shoppingCart.DeliveryInfo.WarehouseCode; } return(true); }
public override string GetShippingInstructionsForDS(MyHLShoppingCart shoppingCart, string distributorID, string locale) { ShippingInfo currentShippingInfo = shoppingCart.DeliveryInfo; if (shoppingCart.DeliveryInfo != null && shoppingCart.DeliveryInfo.Option == DeliveryOptionType.Pickup && HLConfigManager.Configurations.PickupOrDeliveryConfiguration.HasSpecialEventWareHouse && shoppingCart.DeliveryInfo.WarehouseCode == HLConfigManager.Configurations.PickupOrDeliveryConfiguration.SpecialEventWareHouse) { var distributorProfileModel = (MembershipUser <DistributorProfileModel>)Membership.GetUser(); var memberSubType = distributorProfileModel != null ? distributorProfileModel.Value.SubTypeCode : string.Empty; return(string.Format("Honors 2016, {0} MEMBER", memberSubType)); } if (currentShippingInfo.Option == DeliveryOptionType.Pickup) { return(string.Format("{0} A {1} {2} {3} {4} Gracias por su orden.", currentShippingInfo.Description.Trim(), currentShippingInfo.Address.Address.City, currentShippingInfo.Address.Address.PostalCode, currentShippingInfo.Address.Address.StateProvinceTerritory, currentShippingInfo.Address.Recipient)); } else { return(string.Format("{0} A {1} {2} {3} {4} Gracias por su orden.", currentShippingInfo.Name, currentShippingInfo.Address.Address.City, currentShippingInfo.Address.Address.PostalCode, currentShippingInfo.Address.Address.StateProvinceTerritory, currentShippingInfo.Address.Recipient)); } #endregion }
private bool CheckInventory(CatalogItem_V01 catItem) { int inventoryQty = 0; int quantity = 0; if (null != catItem) { if (!string.IsNullOrEmpty(tbQuantity.Text)) { int.TryParse(tbQuantity.Text.Trim(), out quantity); } else { quantity = 0; } MyHLShoppingCart cart = (ProductsBase).ShoppingCart; if (null != cart && null != cart.DeliveryInfo) { inventoryQty = ShoppingCartProvider.CheckInventory(catItem, quantity, cart.DeliveryInfo.WarehouseCode); } } return(inventoryQty > 0); }