public static void SetShipmentTrackingInfo( String ebayOrderLineItemId, Boolean isPaid, String trackingNumber, ShippingMethods shippingMethod, DateTime dateOfShipping) { try { CompleteSaleRequestType request = new CompleteSaleRequestType(); request.OrderLineItemID = ebayOrderLineItemId; request.Paid = isPaid; request.Shipped = true; request.Shipment = new ShipmentType(); request.Shipment.ShippedTime = dateOfShipping; request.Shipment.ShipmentTrackingDetails = new ShipmentTrackingDetailsTypeCollection(); request.Shipment.ShipmentTrackingDetails.Add(new ShipmentTrackingDetailsType() { ShipmentTrackingNumber = trackingNumber, ShippingCarrierUsed = shippingMethod.ToString() }); CompleteSaleCall call = new CompleteSaleCall(EbayController.GetApiContext()); call.ExecuteRequest(request); } catch (Exception ex) { System.Diagnostics.Trace.WriteLine(String.Format("TrackingNumber can't be set. Ebay says: {0}", ex.Message)); } }
public void Initialize() { ShippingMethods.ClearSelection(); ShippingMethods.Items.Clear(); SetMultiShipVisibility(); }
public string FindHightlightColorForOrder(OrderSnapshot o) { string result = ""; if (o == null) { return(result); } if (o.ShippingMethodId.Trim().Length < 1) { return(result); } var m = ShippingMethods.Find(o.ShippingMethodId.Trim()); if (m == null) { return(result); } string highlight = m.Settings.GetSettingOrEmpty("highlight"); if (highlight.Trim().Length > 0) { return(highlight); } return(result); }
public GetShippingMethodsResponse(ShippingMethodResult apiResult) : this() { if (apiResult.ShippingMethods.Any()) { foreach (var method in apiResult.ShippingMethods) { if (method.CybersourceShippingId != null) { if (method.CybersourceShippingId != "pickup") { ShippingMethods.Add(new Option { Name = string.Format("{0} ({1}) - ${2:N2}", method.Name, method.Description, method.Price), Value = method.Id }); } else { ShipToStoreId = method.Id; } } } if (ShippingMethods.Any()) { ShippingMethods.FirstOrDefault().IsSelected = true; } } }
/// <summary> /// Set the info regarding Use Real time rates in a collection /// </summary> /// <returns>Return a collection of shipping method for UseRealtimerates based in the computation of Use Real time rates</returns> public override ShippingMethodCollection GetShippingMethods(int storeId) { ShippingMethodCollection availableShippingMethods = new ShippingMethodCollection(); ShippingMethods s_methods = this.Cart.GetRates(this.ShippingAddress, AppLogic.AppConfigUSDecimal("ShippingHandlingExtraFee")); int Count = 0; if (s_methods.Count > 0) { foreach (ShipMethod s_method in s_methods) { Count++; ShippingMethod realTimeMethod = (ShippingMethod)s_method; realTimeMethod.IsFree &= this.ShippingIsFreeIfIncludedInFreeList; realTimeMethod.IsRealTime = true; if (Cart.ShippingIsFree) { string FreeShippingMethodIDs = Shipping.GetFreeShippingMethodIDs(); if (CommonLogic.IntegerIsInIntegerList(realTimeMethod.Id, FreeShippingMethodIDs)) { realTimeMethod.Freight = 0.0M; realTimeMethod.ShippingIsFree = true; } } bool include = !(this.ExcludeZeroFreightCosts == true && realTimeMethod.Freight == decimal.Zero); if (include) { availableShippingMethods.Add(realTimeMethod); // add it to the db if (DB.GetSqlN("select count(*) as N from ShippingMethod with (NOLOCK) where IsRTShipping=1 and convert(nvarchar(4000),Name)=" + DB.SQuote(realTimeMethod.Name)) == 0) { DB.ExecuteSQL(String.Format("insert ShippingMethod(Name,IsRTShipping) values({0},1)", DB.SQuote(realTimeMethod.Name))); } } } } else if (s_methods.ErrorMsg.IndexOf(AppLogic.AppConfig("RTShipping.CallForShippingPrompt")) != -1) { ShippingMethod onlyCallForPromptShippingMethod = new ShippingMethod(); onlyCallForPromptShippingMethod.Name = AppLogic.AppConfig("RTShipping.CallForShippingPrompt"); onlyCallForPromptShippingMethod.IsRealTime = true; onlyCallForPromptShippingMethod.Id = -1; availableShippingMethods.Add(onlyCallForPromptShippingMethod); } else { ShippingMethod noShippingMethodFound = new ShippingMethod(); noShippingMethodFound.Name = AppLogic.GetString("checkoutshipping.estimator.control.InvalidAddress", ThisCustomer.SkinID, ThisCustomer.LocaleSetting); noShippingMethodFound.IsRealTime = true; noShippingMethodFound.Id = -2; availableShippingMethods.Add(noShippingMethodFound); } return(availableShippingMethods); }
public ForwardTransitResolutionAction(Route route, IEnumerable <Resource> resourceUnits, Location from, Location to, ShippingMethods method) { Route = route; ResourceUnits = resourceUnits; FromLocation = from; ToLocation = to; Method = method; }
public ActionResult DeleteConfirmed(int id) { ShippingMethods shippingmethods = db.ShippingMethods.Find(id); db.ShippingMethods.Remove(shippingmethods); db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult Edit([Bind(Include = "shippingMethodsId,shippingMethodName,taxeRate")] ShippingMethods shippingmethods) { if (ModelState.IsValid) { db.Entry(shippingmethods).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(shippingmethods)); }
public ActionResult Create([Bind(Include = "shippingMethodsId,shippingMethodName,taxeRate")] ShippingMethods shippingmethods) { if (ModelState.IsValid) { db.ShippingMethods.Add(shippingmethods); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(shippingmethods)); }
private void PopulateShippingMethods() { IEnumerable <IShippingMethod> shippingMethods = this.Model.ShippingMethods; var customer = AspDotNetStorefrontCore.Customer.Current; if (!customer.HasAtLeastOneAddress() || (string.IsNullOrEmpty(customer.PrimaryShippingAddress.City) && string.IsNullOrEmpty(customer.PrimaryShippingAddress.State) && string.IsNullOrEmpty(customer.PrimaryShippingAddress.Country))) { ShowError(StringResourceProvider.GetString("smartcheckout.aspx.153")); ShippingMethods.Items.Clear(); this.Disable(); return; } if (shippingMethods.Count() <= 0) { if (!string.IsNullOrEmpty(this.Model.LastShippingMethodError)) { if (AppLogic.AppConfigBool("Vortx.OnePageCheckout.AllowRTShipping.NoMethodSelected")) { ShowError(StringResourceProvider.GetString("smartcheckout.aspx.165")); } else { ShowError(this.Model.LastShippingMethodError); } } else { ShowError(StringResourceProvider.GetString("smartcheckout.aspx.131")); } ShippingMethods.Items.Clear(); this.Disable(); return; } if (CartContentsChanged && shippingMethods.Count() > 0) { ShowErrorWithCss(StringResourceProvider.GetString("smartcheckout.aspx.166"), "error-wrap"); } else { PanelError.CssClass = string.Empty; PanelError.Visible = false; } ShippingMethods.DataSource = shippingMethods; ShippingMethods.DataTextField = "DisplayName"; ShippingMethods.DataValueField = "Identifier"; ShippingMethods.DataBind(); }
public OperationDetails SetShippingMethod(string userId, ShippingMethods method) { CheckOut checkOut = unitOfWork.CheckOutRepository.GetByID(userId); if (checkOut == null) { return(new OperationDetails(false, "خطأ ما أثناء عملية التعديل", "")); } checkOut.SelectedShippingMethod = (long)method; unitOfWork.CheckOutRepository.Update(checkOut); unitOfWork.Save(); return(new OperationDetails(true, "تمت عملية التعديل بنجاح", "")); }
public void ShippingMethods_Serialize_PropertyNamesAsExpected() { // Arrange var shippingMethods = new ShippingMethods(); // Act var serializedObject = JsonConvert.SerializeObject(shippingMethods); // Assert Assert.AreEqual(@"{ ""flat_rate_shipping"": null, ""pickup"": null }" .RemoveWhiteSpace(), serializedObject.RemoveWhiteSpace()); }
// GET: /ShippingMethods/Delete/5 public ActionResult Delete(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } ShippingMethods shippingmethods = db.ShippingMethods.Find(id); if (shippingmethods == null) { return(HttpNotFound()); } return(View(shippingmethods)); }
private void CreateAndReassign(Zone zone) { var methods = ShippingMethods.FindForZones(new List <Zone> { zone }); if (ShippingZones.Create(zone)) { methods.ForEach(m => { m.ZoneId = zone.Id; ShippingMethods.Update(m); }); } }
public string FindHighlightForOrder(OrderSnapshot order) { if (order == null || string.IsNullOrWhiteSpace(order.ShippingMethodId)) { return(null); } var method = ShippingMethods.Find(order.ShippingMethodId.Trim()); if (method == null) { return(null); } var highlight = method.Settings.GetSettingOrEmpty("highlight"); return(highlight); }
private void PopulateShippingMethods() { IEnumerable <IShippingMethod> shippingMethods = this.ShoppingCartModel.ShippingMethods; if (shippingMethods.Count() <= 0) { ShowError(StringResourceProvider.GetString("smartcheckout.aspx.131")); ShippingMethods.Items.Clear(); this.Disable(); } else { PanelError.Visible = false; ShippingMethods.DataSource = shippingMethods; ShippingMethods.DataTextField = "DisplayName"; ShippingMethods.DataValueField = "Identifier"; ShippingMethods.DataBind(); } }
public virtual void Patch(StoreEntity target) { if (target == null) { throw new ArgumentNullException(nameof(target)); } target.AdminEmail = AdminEmail; target.Catalog = Catalog; target.Country = Country; target.DefaultCurrency = DefaultCurrency; target.DefaultLanguage = DefaultLanguage; target.Description = Description; target.DisplayOutOfStock = DisplayOutOfStock; target.Email = Email; target.ModifiedBy = ModifiedBy; target.ModifiedDate = ModifiedDate; target.Name = Name; target.Region = Region; target.SecureUrl = SecureUrl; target.TimeZone = TimeZone; target.Url = Url; target.StoreState = (int)StoreState; target.FulfillmentCenterId = FulfillmentCenterId; target.ReturnsFulfillmentCenterId = ReturnsFulfillmentCenterId; if (!Languages.IsNullCollection()) { var languageComparer = AnonymousComparer.Create((StoreLanguageEntity x) => x.LanguageCode); Languages.Patch(target.Languages, languageComparer, (sourceLang, targetLang) => targetLang.LanguageCode = sourceLang.LanguageCode); } if (!Currencies.IsNullCollection()) { var currencyComparer = AnonymousComparer.Create((StoreCurrencyEntity x) => x.CurrencyCode); Currencies.Patch(target.Currencies, currencyComparer, (sourceCurrency, targetCurrency) => targetCurrency.CurrencyCode = sourceCurrency.CurrencyCode); } if (!TrustedGroups.IsNullCollection()) { var trustedGroupComparer = AnonymousComparer.Create((StoreTrustedGroupEntity x) => x.GroupName); TrustedGroups.Patch(target.TrustedGroups, trustedGroupComparer, (sourceGroup, targetGroup) => sourceGroup.GroupName = targetGroup.GroupName); } if (!PaymentMethods.IsNullCollection()) { var paymentComparer = AnonymousComparer.Create((StorePaymentMethodEntity x) => x.Code); PaymentMethods.Patch(target.PaymentMethods, paymentComparer, (sourceMethod, targetMethod) => sourceMethod.Patch(targetMethod)); } if (!ShippingMethods.IsNullCollection()) { var shippingComparer = AnonymousComparer.Create((StoreShippingMethodEntity x) => x.Code); ShippingMethods.Patch(target.ShippingMethods, shippingComparer, (sourceMethod, targetMethod) => sourceMethod.Patch(targetMethod)); } if (!TaxProviders.IsNullCollection()) { var shippingComparer = AnonymousComparer.Create((StoreTaxProviderEntity x) => x.Code); TaxProviders.Patch(target.TaxProviders, shippingComparer, (sourceProvider, targetProvider) => sourceProvider.Patch(targetProvider)); } if (!FulfillmentCenters.IsNullCollection()) { var fulfillmentCenterComparer = AnonymousComparer.Create((StoreFulfillmentCenterEntity fc) => $"{fc.FulfillmentCenterId}-{fc.Type}"); FulfillmentCenters.Patch(target.FulfillmentCenters, fulfillmentCenterComparer, (sourceFulfillmentCenter, targetFulfillmentCenter) => sourceFulfillmentCenter.Patch(targetFulfillmentCenter)); } }
private void FilterRatesByShippingMethods(SortableCollection <ShippingRateDisplay> ratesSort, Order order) { var shippingProviders = ShippingMethods.FindAll(order.StoreId); shippingProviders = shippingProviders.OrderBy(s => s.SortOrder).ToList(); var subtotal = false; var rates = ratesSort.ToList(); foreach (var method in shippingProviders) { var filteredrates = rates.Where(r => r.ShippingMethodId == method.Bvin).ToList(); foreach (var rate in filteredrates) { if (rate != null) { if (method.VisibilityMode == ShippingVisibilityMode.Always) { subtotal = true; } else if (method.VisibilityMode == ShippingVisibilityMode.Never) { ratesSort.Remove(rate); } else if (method.VisibilityMode == ShippingVisibilityMode.NoRates) { if (subtotal) { ratesSort.Remove(rate); } else { subtotal = true; } } else if (method.VisibilityMode == ShippingVisibilityMode.SubtotalAmount) { if (method.VisibilityAmount.HasValue && order.TotalOrderAfterDiscounts > method.VisibilityAmount.Value) { subtotal = true; } else { ratesSort.Remove(rate); } } else if (method.VisibilityMode == ShippingVisibilityMode.TotalWeight) { if (method.VisibilityAmount.HasValue && order.TotalWeight > method.VisibilityAmount.Value) { subtotal = true; } else { ratesSort.Remove(rate); } } } } } }
public Route(ShippingMethods routeType, Location l1, Location l2) { EligibleShippingMethods = routeType; Location1 = l1; Location2 = l2; }
public void WriteShippingXML(XmlWriter writer, int VariantID, decimal Price, decimal Weight, int CountryID, int StateID, int ZoneID) { bool AnyShippingMethodsFound = false; bool ShippingMethodToStateMapIsEmpty = Shipping.ShippingMethodToStateMapIsEmpty(); bool ShippingMethodToCountryMapIsEmpty = Shipping.ShippingMethodToCountryMapIsEmpty(); bool ShippingMethodToZoneMapIsEmpty = Shipping.ShippingMethodToZoneMapIsEmpty(); int FreeShippingMethodID = 0; if (AppLogic.AppConfigUSInt("ShippingMethodIDIfFreeShippingIsOn") != 0) { FreeShippingMethodID = AppLogic.AppConfigUSInt("ShippingMethodIDIfFreeShippingIsOn"); } bool ShippingIsFree = false; if (Price > AppLogic.AppConfigUSDecimal("FreeShippingThreshold")) { ShippingIsFree = true; } Shipping.ShippingCalculationEnum ShipCalcID = Shipping.GetActiveShippingCalculationID(); decimal ExtraFee = AppLogic.AppConfigUSDecimal("ShippingHandlingExtraFee"); switch (ShipCalcID) { case Shipping.ShippingCalculationEnum.CalculateShippingByWeight: { writer.WriteStartElement("Shipping"); writer.WriteAttributeString("Method", "CalculateShippingByWeight"); StringBuilder shipsql = new StringBuilder(4096); shipsql.Append("select * from ShippingMethod with (NOLOCK) where IsRTShipping=0 "); if (!ShippingMethodToStateMapIsEmpty) { shipsql.Append(" and ShippingMethodID in (select ShippingMethodID from ShippingMethodToStateMap with (NOLOCK) where StateID=" + StateID + ")"); } if (!ShippingMethodToCountryMapIsEmpty) { shipsql.Append(" and ShippingMethodID in (select ShippingMethodID from ShippingMethodToCountryMap with (NOLOCK) where CountryID=" + CountryID + ")"); } if (!ShippingMethodToZoneMapIsEmpty) { shipsql.Append(" and ShippingMethodID in (select ShippingMethodID from ShippingMethodToZoneMap with (NOLOCK) where ShippingZoneID=" + ZoneID + ")"); } shipsql.Append(" order by Displayorder"); using (SqlConnection con = new SqlConnection(DB.GetDBConn())) { con.Open(); using (IDataReader rs = DB.GetRS(shipsql.ToString(), con)) { while (rs.Read()) { int ThisID = DB.RSFieldInt(rs, "ShippingMethodID"); if (ShippingIsFree && ThisID == FreeShippingMethodID) { writer.WriteElementString("Method" + ThisID.ToString(), Shipping.GetShippingMethodDisplayName(ThisID, null) + ": " + AppLogic.GetString("shoppingcart.aspx.16", ThisCustomer.SkinID, ThisCustomer.LocaleSetting)); } else { Decimal ThisShipCost = Shipping.GetShipByWeightCharge(ThisID, Weight) + ExtraFee; if (ThisShipCost != System.Decimal.Zero || !AppLogic.AppConfigBool("FilterOutShippingMethodsThatHave0Cost")) { AnyShippingMethodsFound = true; writer.WriteElementString("Method" + ThisID.ToString(), Shipping.GetShippingMethodDisplayName(ThisID, null) + ": " + Localization.CurrencyStringForDisplayWithoutExchangeRate(ThisShipCost)); } } } } } if (!AnyShippingMethodsFound) { writer.WriteElementString("Method0", "No Matching Shipping Methods Found For That Country/State/Postal Code"); } writer.WriteEndElement(); break; } case Shipping.ShippingCalculationEnum.CalculateShippingByTotal: { writer.WriteStartElement("Shipping"); writer.WriteAttributeString("Method", "CalculateShippingByTotal"); StringBuilder shipsql = new StringBuilder(1024); shipsql.Append("select * from ShippingMethod with (NOLOCK) where IsRTShipping=0 "); if (!ShippingMethodToStateMapIsEmpty) { shipsql.Append(" and ShippingMethodID in (select ShippingMethodID from ShippingMethodToStateMap with (NOLOCK) where StateID=" + StateID + ")"); } if (!ShippingMethodToCountryMapIsEmpty) { shipsql.Append(" and ShippingMethodID in (select ShippingMethodID from ShippingMethodToCountryMap with (NOLOCK) where CountryID=" + CountryID + ")"); } if (!ShippingMethodToZoneMapIsEmpty) { shipsql.Append(" and ShippingMethodID in (select ShippingMethodID from ShippingMethodToZoneMap with (NOLOCK) where ShippingZoneID=" + ZoneID + ")"); } shipsql.Append(" order by Displayorder"); using (SqlConnection con = new SqlConnection(DB.GetDBConn())) { con.Open(); using (IDataReader rs = DB.GetRS(shipsql.ToString(), con)) { while (rs.Read()) { int ThisID = DB.RSFieldInt(rs, "ShippingMethodID"); if (ShippingIsFree && ThisID == FreeShippingMethodID) { writer.WriteElementString("Method" + ThisID.ToString(), Shipping.GetShippingMethodDisplayName(ThisID, null) + ": FREE"); } else { Decimal ThisShipCost = Shipping.GetShipByTotalCharge(ThisID, Price) + ExtraFee; // exclude download items! if (ThisShipCost != System.Decimal.Zero || !AppLogic.AppConfigBool("FilterOutShippingMethodsThatHave0Cost")) { AnyShippingMethodsFound = true; writer.WriteElementString("Method" + ThisID.ToString(), Shipping.GetShippingMethodDisplayName(ThisID, null) + ": " + Localization.CurrencyStringForDisplayWithoutExchangeRate(ThisShipCost)); } } } } } if (!AnyShippingMethodsFound) { writer.WriteElementString("Method0", "No Matching Shipping Methods Found For That Country/State/Postal Code"); } writer.WriteEndElement(); break; } case Shipping.ShippingCalculationEnum.UseFixedPrice: { writer.WriteStartElement("Shipping"); writer.WriteAttributeString("Method", "UseFixedPrice"); StringBuilder shipsql = new StringBuilder(1024); shipsql.Append("select * from ShippingMethod with (NOLOCK) where IsRTShipping=0 "); if (!ShippingMethodToStateMapIsEmpty) { shipsql.Append(" and ShippingMethodID in (select ShippingMethodID from ShippingMethodToStateMap with (NOLOCK) where StateID=" + StateID + ")"); } if (!ShippingMethodToCountryMapIsEmpty) { shipsql.Append(" and ShippingMethodID in (select ShippingMethodID from ShippingMethodToCountryMap with (NOLOCK) where CountryID=" + CountryID + ")"); } if (!ShippingMethodToZoneMapIsEmpty) { shipsql.Append(" and ShippingMethodID in (select ShippingMethodID from ShippingMethodToZoneMap with (NOLOCK) where ShippingZoneID=" + ZoneID + ")"); } shipsql.Append(" order by Displayorder"); using (SqlConnection con = new SqlConnection(DB.GetDBConn())) { con.Open(); using (IDataReader rs = DB.GetRS(shipsql.ToString(), con)) { while (rs.Read()) { int ThisID = DB.RSFieldInt(rs, "ShippingMethodID"); if (ShippingIsFree && ThisID == FreeShippingMethodID) { writer.WriteElementString("Method" + ThisID.ToString(), Shipping.GetShippingMethodDisplayName(ThisID, null) + ": FREE"); } else { Decimal ThisShipCost = (decimal)DB.RSFieldDecimal(rs, "FixedRate") + ExtraFee; if (ThisShipCost != System.Decimal.Zero || !AppLogic.AppConfigBool("FilterOutShippingMethodsThatHave0Cost")) { AnyShippingMethodsFound = true; writer.WriteElementString("Method" + ThisID.ToString(), Shipping.GetShippingMethodDisplayName(ThisID, null) + ": " + Localization.CurrencyStringForDisplayWithoutExchangeRate(ThisShipCost)); } } } } } if (!AnyShippingMethodsFound) { writer.WriteElementString("Method0", "No Matching Shipping Methods Found For That Country/State/Postal Code"); } writer.WriteEndElement(); break; } case Shipping.ShippingCalculationEnum.AllOrdersHaveFreeShipping: AnyShippingMethodsFound = true; writer.WriteStartElement("Shipping"); writer.WriteAttributeString("Method", "AllOrdersHaveFreeShipping"); writer.WriteElementString("Method1", "All Orders Have Free Shipping"); writer.WriteEndElement(); break; case Shipping.ShippingCalculationEnum.UseFixedPercentageOfTotal: { writer.WriteStartElement("Shipping"); writer.WriteAttributeString("Method", "UseFixedPercentageOfTotal"); StringBuilder shipsql = new StringBuilder(1024); shipsql.Append("select * from ShippingMethod with (NOLOCK) where IsRTShipping=0 "); if (!ShippingMethodToStateMapIsEmpty) { shipsql.Append(" and ShippingMethodID in (select ShippingMethodID from ShippingMethodToStateMap with (NOLOCK) where StateID=" + StateID + ")"); } if (!ShippingMethodToCountryMapIsEmpty) { shipsql.Append(" and ShippingMethodID in (select ShippingMethodID from ShippingMethodToCountryMap with (NOLOCK) where CountryID=" + CountryID + ")"); } if (!ShippingMethodToZoneMapIsEmpty) { shipsql.Append(" and ShippingMethodID in (select ShippingMethodID from ShippingMethodToZoneMap with (NOLOCK) where ShippingZoneID=" + ZoneID + ")"); } shipsql.Append(" order by Displayorder"); using (SqlConnection con = new SqlConnection(DB.GetDBConn())) { con.Open(); using (IDataReader rs = DB.GetRS(shipsql.ToString(), con)) { while (rs.Read()) { int ThisID = DB.RSFieldInt(rs, "ShippingMethodID"); if (ShippingIsFree && ThisID == FreeShippingMethodID) { writer.WriteElementString("Method" + ThisID.ToString(), Shipping.GetShippingMethodDisplayName(ThisID, null) + ": FREE"); } else { Decimal ThisShipCost = Shipping.GetShipByFixedPercentageCharge(ThisID, Price) + ExtraFee; if (ThisShipCost != System.Decimal.Zero || !AppLogic.AppConfigBool("FilterOutShippingMethodsThatHave0Cost")) { AnyShippingMethodsFound = true; writer.WriteElementString("Method" + ThisID.ToString(), Shipping.GetShippingMethodDisplayName(ThisID, null) + ": " + Localization.CurrencyStringForDisplayWithoutExchangeRate(ThisShipCost)); } } } } } if (!AnyShippingMethodsFound) { writer.WriteElementString("Method0", "No Matching Shipping Methods Found For That Country/State/Postal Code"); } writer.WriteEndElement(); break; } case Shipping.ShippingCalculationEnum.UseIndividualItemShippingCosts: { writer.WriteStartElement("Shipping"); writer.WriteAttributeString("Method", "UseIndividualItemShippingCosts"); StringBuilder shipsql = new StringBuilder(1024); shipsql.Append("select * from ShippingMethod with (NOLOCK) where IsRTShipping=0 "); if (!ShippingMethodToStateMapIsEmpty) { shipsql.Append(" and ShippingMethodID in (select ShippingMethodID from ShippingMethodToStateMap with (NOLOCK) where StateID=" + StateID + ")"); } if (!ShippingMethodToCountryMapIsEmpty) { shipsql.Append(" and ShippingMethodID in (select ShippingMethodID from ShippingMethodToCountryMap with (NOLOCK) where CountryID=" + CountryID + ")"); } if (!ShippingMethodToZoneMapIsEmpty) { shipsql.Append(" and ShippingMethodID in (select ShippingMethodID from ShippingMethodToZoneMap with (NOLOCK) where ShippingZoneID=" + ZoneID + ")"); } shipsql.Append(" order by Displayorder"); using (SqlConnection con = new SqlConnection(DB.GetDBConn())) { con.Open(); using (IDataReader rs = DB.GetRS(shipsql.ToString(), con)) { while (rs.Read()) { int ThisID = DB.RSFieldInt(rs, "ShippingMethodID"); if (ShippingIsFree && ThisID == FreeShippingMethodID) { writer.WriteElementString("Method" + ThisID.ToString(), Shipping.GetShippingMethodDisplayName(ThisID, null) + ": FREE"); } else { Decimal ThisShipCost = Shipping.GetVariantShippingCost(VariantID, ThisID) + ExtraFee; if (ThisShipCost != System.Decimal.Zero || !AppLogic.AppConfigBool("FilterOutShippingMethodsThatHave0Cost")) { AnyShippingMethodsFound = true; writer.WriteElementString("Method" + ThisID.ToString(), Shipping.GetShippingMethodDisplayName(ThisID, null) + ": " + Localization.CurrencyStringForDisplayWithoutExchangeRate(ThisShipCost)); } } } } } if (!AnyShippingMethodsFound) { writer.WriteElementString("Method0", "No Matching Shipping Methods Found For That Country/State/Postal Code"); } writer.WriteEndElement(); break; } case Shipping.ShippingCalculationEnum.CalculateShippingByWeightAndZone: { writer.WriteStartElement("Shipping"); writer.WriteAttributeString("Method", "CalculateShippingByWeightAndZone"); StringBuilder shipsql = new StringBuilder(1024); shipsql.Append("select * from ShippingMethod with (NOLOCK) where IsRTShipping=0 "); if (!ShippingMethodToStateMapIsEmpty) { shipsql.Append(" and ShippingMethodID in (select ShippingMethodID from ShippingMethodToStateMap with (NOLOCK) where StateID=" + StateID + ")"); } if (!ShippingMethodToCountryMapIsEmpty) { shipsql.Append(" and ShippingMethodID in (select ShippingMethodID from ShippingMethodToCountryMap with (NOLOCK) where CountryID=" + CountryID + ")"); } if (!ShippingMethodToZoneMapIsEmpty) { shipsql.Append(" and ShippingMethodID in (select ShippingMethodID from ShippingMethodToZoneMap with (NOLOCK) where ShippingZoneID=" + ZoneID + ")"); } shipsql.Append(" order by Displayorder"); using (SqlConnection con = new SqlConnection(DB.GetDBConn())) { con.Open(); using (IDataReader rs = DB.GetRS(shipsql.ToString(), con)) { while (rs.Read()) { int ThisID = DB.RSFieldInt(rs, "ShippingMethodID"); if (ShippingIsFree && ThisID == FreeShippingMethodID) { writer.WriteElementString("Method" + ThisID.ToString(), Shipping.GetShippingMethodDisplayName(ThisID, null) + ": FREE"); } else { Decimal ThisShipCost = Shipping.GetShipByWeightAndZoneCharge(ThisID, Weight, ZoneID) + ExtraFee; if (ThisShipCost != System.Decimal.Zero || !AppLogic.AppConfigBool("FilterOutShippingMethodsThatHave0Cost")) { AnyShippingMethodsFound = true; writer.WriteElementString("Method" + ThisID.ToString(), Shipping.GetShippingMethodDisplayName(ThisID, null) + ": " + Localization.CurrencyStringForDisplayWithoutExchangeRate(ThisShipCost)); } } } } } if (!AnyShippingMethodsFound) { writer.WriteElementString("Method0", "No Matching Shipping Methods Found For That Country/State/Postal Code"); } writer.WriteEndElement(); break; } case Shipping.ShippingCalculationEnum.CalculateShippingByTotalAndZone: { writer.WriteStartElement("Shipping"); writer.WriteAttributeString("Method", "CalculateShippingByTotalAndZone"); StringBuilder shipsql = new StringBuilder(1024); shipsql.Append("select * from ShippingMethod with (NOLOCK) where IsRTShipping=0 "); if (!ShippingMethodToStateMapIsEmpty) { shipsql.Append(" and ShippingMethodID in (select ShippingMethodID from ShippingMethodToStateMap with (NOLOCK) where StateID=" + StateID + ")"); } if (!ShippingMethodToCountryMapIsEmpty) { shipsql.Append(" and ShippingMethodID in (select ShippingMethodID from ShippingMethodToCountryMap with (NOLOCK) where CountryID=" + CountryID + ")"); } if (!ShippingMethodToZoneMapIsEmpty) { shipsql.Append(" and ShippingMethodID in (select ShippingMethodID from ShippingMethodToZoneMap with (NOLOCK) where ShippingZoneID=" + ZoneID + ")"); } shipsql.Append(" order by Displayorder"); using (SqlConnection con = new SqlConnection(DB.GetDBConn())) { con.Open(); using (IDataReader rs = DB.GetRS(shipsql.ToString(), con)) { while (rs.Read()) { int ThisID = DB.RSFieldInt(rs, "ShippingMethodID"); if (ShippingIsFree && ThisID == FreeShippingMethodID) { writer.WriteElementString("Method" + ThisID.ToString(), Shipping.GetShippingMethodDisplayName(ThisID, null) + ": FREE"); } else { Decimal ThisShipCost = Shipping.GetShipByTotalAndZoneCharge(ThisID, Price, ZoneID) + ExtraFee; if (ThisShipCost != System.Decimal.Zero || !AppLogic.AppConfigBool("FilterOutShippingMethodsThatHave0Cost")) { AnyShippingMethodsFound = true; writer.WriteElementString("Method" + ThisID.ToString(), Shipping.GetShippingMethodDisplayName(ThisID, null) + ": " + Localization.CurrencyStringForDisplayWithoutExchangeRate(ThisShipCost)); } } } } } if (!AnyShippingMethodsFound) { writer.WriteElementString("Method0", "No Matching Shipping Methods Found For That Country/State/Postal Code"); } writer.WriteEndElement(); break; } case Shipping.ShippingCalculationEnum.CalculateShippingByTotalByPercent: { writer.WriteStartElement("Shipping"); writer.WriteAttributeString("Method", "CalculateShippingByTotalByPercent"); StringBuilder shipsql = new StringBuilder(1024); shipsql.Append("select * from ShippingMethod with (NOLOCK) where IsRTShipping=0 "); if (!ShippingMethodToStateMapIsEmpty) { shipsql.Append(" and ShippingMethodID in (select ShippingMethodID from ShippingMethodToStateMap with (NOLOCK) where StateID=" + StateID + ")"); } if (!ShippingMethodToCountryMapIsEmpty) { shipsql.Append(" and ShippingMethodID in (select ShippingMethodID from ShippingMethodToCountryMap with (NOLOCK) where CountryID=" + CountryID + ")"); } if (!ShippingMethodToZoneMapIsEmpty) { shipsql.Append(" and ShippingMethodID in (select ShippingMethodID from ShippingMethodToZoneMap with (NOLOCK) where ShippingZoneID=" + ZoneID + ")"); } shipsql.Append(" order by Displayorder"); using (SqlConnection con = new SqlConnection(DB.GetDBConn())) { con.Open(); using (IDataReader rs = DB.GetRS(shipsql.ToString(), con)) { while (rs.Read()) { int ThisID = DB.RSFieldInt(rs, "ShippingMethodID"); if (ShippingIsFree && ThisID == FreeShippingMethodID) { writer.WriteElementString("Method" + ThisID.ToString(), Shipping.GetShippingMethodDisplayName(ThisID, null) + ": FREE"); } else { Decimal ThisShipCost = Shipping.GetShipByTotalByPercentCharge(ThisID, Price) + ExtraFee; if (ThisShipCost != System.Decimal.Zero || !AppLogic.AppConfigBool("FilterOutShippingMethodsThatHave0Cost")) { AnyShippingMethodsFound = true; writer.WriteElementString("Method" + ThisID.ToString(), Shipping.GetShippingMethodDisplayName(ThisID, null) + ": " + Localization.CurrencyStringForDisplayWithoutExchangeRate(ThisShipCost)); } } } } } if (!AnyShippingMethodsFound) { writer.WriteElementString("Method0", "No Matching Shipping Methods Found For That Country/State/Postal Code"); } writer.WriteEndElement(); break; } case Shipping.ShippingCalculationEnum.UseRealTimeRates: { writer.WriteStartElement("Shipping"); writer.WriteAttributeString("Method", "UseRealTimeRates"); ShippingMethods SM = GetRates(); if (SM.Count > 0) { int ThisID = 1; foreach (ShipMethod meth in SM) { if (meth.ServiceRate != System.Decimal.Zero || !AppLogic.AppConfigBool("FilterOutShippingMethodsThatHave0Cost")) { writer.WriteElementString("Method" + ThisID.ToString(), meth.ServiceName + ": " + Localization.CurrencyStringForDisplayWithoutExchangeRate(meth.ServiceRate)); ThisID++; } } } else if (SM.ErrorMsg.Length != 0) { if (SM.ErrorMsg.IndexOf(AppLogic.AppConfig("RTShipping.CallForShippingPrompt")) != -1) { writer.WriteElementString("Method0", AppLogic.AppConfig("RTShipping.CallForShippingPrompt")); } else { writer.WriteElementString("Method0", SM.ErrorMsg); } } else { writer.WriteElementString("Method0", "No Matching Shipping Methods Found For That Country/State/Postal Code"); } writer.WriteEndElement(); break; } } }
private SortableCollection <ShippingRateDisplay> FindAvailableShippingRatesInternal(Order order, string shippingMethodIdFilter = null) { if (order == null) { return(new SortableCollection <ShippingRateDisplay>()); } var result = new SortableCollection <ShippingRateDisplay>(); // Get all the methods that apply to this shipping address and store var zones = ShippingZones.FindAllZonesForAddress(order.ShippingAddress, order.StoreId); var methods = ShippingMethods.FindForZones(zones); if (!string.IsNullOrEmpty(shippingMethodIdFilter)) { methods = methods.Where(m => m.Bvin == shippingMethodIdFilter).ToList(); } // Get Rates for each Method if (!order.IsOrderFreeShipping()) { var tasks = new List <Task <Collection <ShippingRateDisplay> > >(); foreach (var method in methods) { var task = Task.Factory.StartNew(hccContext => { HccRequestContext.Current = hccContext as HccRequestContext; return(method.GetRates(order, Context.CurrentStore)); }, HccRequestContext.Current); tasks.Add(task); } Task.WaitAll(tasks.ToArray()); foreach (var task in tasks) { var tempRates = task.Result; if (tempRates != null) { for (var i = 0; i <= tempRates.Count - 1; i++) { var fRate = tempRates[i].GetCopy(); result.Add(fRate); } } } } // Update results with extra ship fees and handling foreach (ShippingRateDisplay displayRate in result) { // Tally up extra ship fees var totalExtraFees = 0m; foreach (var li in order.Items) { if (li.ExtraShipCharge > 0 && !li.MarkedForFreeShipping(displayRate.ShippingMethodId) && li.ShippingCharge == ShippingChargeType.ChargeShippingAndHandling || li.ShippingCharge == ShippingChargeType.ChargeShipping) { totalExtraFees += li.ExtraShipCharge * li.Quantity; } } displayRate.Rate += totalExtraFees + order.TotalHandling; } // Apply promotions to rates here var membershipServices = Factory.CreateService <MembershipServices>(); CustomerAccount currentUser = null; if (order.UserID != string.Empty) { currentUser = membershipServices.Customers.Find(order.UserID); } var marketingServices = Factory.CreateService <MarketingService>(); var offers = marketingServices.Promotions.FindAllPotentiallyActive(DateTime.UtcNow, PromotionType.OfferForShipping); foreach (ShippingRateDisplay displayRate in result) { foreach (var offer in offers) { if (offer.DoNotCombine && order.HasAnyNonSaleDiscounts) { continue; } var newRate = offer.ApplyToShippingRate(Context, order, currentUser, displayRate.ShippingMethodId, displayRate.Rate); if (newRate < displayRate.Rate) { var discount = -1 * (newRate - displayRate.Rate); displayRate.PotentialDiscount = discount; } } } //Changes to have free shipping available for single item in cart by promotion set for "Order Items" - 9May2016-Tushar var offersForLineItems = marketingServices.Promotions.FindAllPotentiallyActive(DateTime.UtcNow, PromotionType.OfferForLineItems); foreach (ShippingRateDisplay displayRate in result) { foreach (var offer in offersForLineItems) { var context = new PromotionContext(Context, PromotionType.OfferForLineItems, offer.Id) { Order = order, CurrentCustomer = currentUser, CustomerDescription = offer.CustomerDescription, CurrentShippingMethodId = displayRate.ShippingMethodId, AdjustedShippingRate = displayRate.Rate, OtherOffersApplied = order.HasAnyNonSaleDiscounts }; var isQualified = offer.ApplyForFreeShipping(context); if (order.Items.Count == 1 || order.IsOrderHasAllItemsQualifiedFreeShipping()) { var isFreeShippingAction = offer.Actions.Where( p => p.TypeId.ToString() == LineItemFreeShipping.TypeIdString && p.Settings.ContainsKey("methodids") && p.Settings["methodids"].ToUpperInvariant() .Contains(displayRate.ShippingMethodId.ToUpperInvariant())).ToList(); if (isFreeShippingAction.Count > 0 && isQualified) { displayRate.PotentialDiscount = displayRate.Rate; } } } } //End changes to have free shipping available for single item in cart by promotion set for "Order Items" - 9May2016-Tushar FilterRatesByShippingMethods(result, order); // Sort Rates result.Sort("Rate", SortDirection.Ascending); if (result.Count < 1) { if (order.IsOrderFreeShipping()) { var rateName = order.TotalHandling > 0 ? GlobalLocalization.GetString("Handling") : GlobalLocalization.GetString("FreeShipping"); result.Add(new ShippingRateDisplay(rateName, "", "", order.TotalHandling, ShippingMethod.MethodFreeShipping)); } else { result.Add(new ShippingRateDisplay(GlobalLocalization.GetString("ToBeDetermined"), string.Empty, string.Empty, 0m, ShippingMethod.MethodToBeDetermined)); } } return(result); }
public IShippingStrategy GetShippingMethods(ShippingMethods shippingMethod) { return(AvailableShippingMethods[shippingMethod]); }