/// <summary> /// Summary for calculation ShippingByTotalByPercent /// </summary> /// <returns>Return a collection of ShippingMethod based on the computation of ShippingByTotalByPercent</returns> public override ShippingMethodCollection GetShippingMethods(int storeId) { ShippingMethodCollection availableShippingMethods = new ShippingMethodCollection(); bool shippingMethodToStateMapIsEmpty = Shipping.ShippingMethodToStateMapIsEmpty(); bool shippingMethodToCountryMapIsEmpty = Shipping.ShippingMethodToCountryMapIsEmpty(); decimal extraFee = AppLogic.AppConfigUSDecimal("ShippingHandlingExtraFee"); string shipsql = GenerateShippingMethodsQuery(storeId, false); //shipsql.Append("select * from ShippingMethod with (NOLOCK) where IsRTShipping=0 "); //if (!shippingMethodToStateMapIsEmpty && !ThisCustomer.IsRegistered) //{ // shipsql.Append(" and ShippingMethodID in (select ShippingMethodID from ShippingMethodToStateMap with (NOLOCK))"); //} //if (!shippingMethodToStateMapIsEmpty && ThisCustomer.IsRegistered) //{ // shipsql.Append(" and ShippingMethodID in (select ShippingMethodID from ShippingMethodToStateMap with (NOLOCK) where StateID=" + AppLogic.GetStateID(this.ShippingAddress.State).ToString() + ")"); //} //if (!shippingMethodToCountryMapIsEmpty) //{ // shipsql.Append(" and ShippingMethodID in (select ShippingMethodID from ShippingMethodToCountryMap with (NOLOCK) where CountryID=" + AppLogic.GetCountryID(this.ShippingAddress.Country).ToString() + ")"); //} //shipsql.Append(" order by Displayorder"); decimal SubTotalWithoutDownload = this.Cart.SubTotal(true, false, false, true, true, false, 0, true); using (SqlConnection dbconn = new SqlConnection(DB.GetDBConn())) { dbconn.Open(); using (IDataReader reader = DB.GetRS(shipsql.ToString(), dbconn)) { while (reader.Read()) { ShippingMethod thisMethod = new ShippingMethod(); thisMethod.Id = DB.RSFieldInt(reader, "ShippingMethodID"); thisMethod.Name = DB.RSFieldByLocale(reader, "Name", ThisCustomer.LocaleSetting); thisMethod.IsFree = this.ShippingIsFreeIfIncludedInFreeList && Shipping.ShippingMethodIsInFreeList(thisMethod.Id); if (thisMethod.IsFree) { thisMethod.Freight = decimal.Zero; thisMethod.ShippingIsFree = true; } else { decimal freight = Shipping.GetShipByTotalByPercentCharge(thisMethod.Id, SubTotalWithoutDownload); // exclude download items! if (extraFee > System.Decimal.Zero) { freight += extraFee; } else if (freight > System.Decimal.Zero && extraFee > System.Decimal.Zero) { freight += extraFee; } if (freight < 0) { freight = 0; } thisMethod.Freight = freight; } bool include = !(this.ExcludeZeroFreightCosts == true && (thisMethod.Freight == decimal.Zero && !thisMethod.IsFree)); if (include) { availableShippingMethods.Add(thisMethod); } } } } return(availableShippingMethods); }
/// <summary> /// Represent the calculation ShippingByWeightAndZone /// </summary> /// <returns>return collection of shipping method based on the computation of ShippingByWeightAndZone </returns> public override ShippingMethodCollection GetShippingMethods(int storeId) { ShippingMethodCollection availableShippingMethods = new ShippingMethodCollection(); bool shippingMethodToStateMapIsEmpty = Shipping.ShippingMethodToStateMapIsEmpty(); bool shippingMethodToCountryMapIsEmpty = Shipping.ShippingMethodToCountryMapIsEmpty(); bool shippingMethodToZoneMapIsEmpty = Shipping.ShippingMethodToZoneMapIsEmpty(); decimal extraFee = AppLogic.AppConfigUSDecimal("ShippingHandlingExtraFee"); string shipsql = GenerateShippingMethodsQuery(storeId, true); ShoppingCart weight = new ShoppingCart(1, ThisCustomer, CartTypeEnum.ShoppingCart, 0, false); using (SqlConnection dbconn = new SqlConnection(DB.GetDBConn())) { dbconn.Open(); using (IDataReader reader = DB.GetRS(shipsql.ToString(), dbconn)) { while (reader.Read()) { ShippingMethod thisMethod = new ShippingMethod(); thisMethod.Id = DB.RSFieldInt(reader, "ShippingMethodID"); thisMethod.Name = DB.RSFieldByLocale(reader, "Name", ThisCustomer.LocaleSetting); thisMethod.IsFree = this.ShippingIsFreeIfIncludedInFreeList && Shipping.ShippingMethodIsInFreeList(thisMethod.Id); if (thisMethod.IsFree) { thisMethod.ShippingIsFree = true; thisMethod.Freight = decimal.Zero; } else { int ZoneID = Shipping.ZoneLookup(this.ShippingAddress.Zip); decimal freight = Shipping.GetShipByWeightAndZoneCharge(thisMethod.Id, weight.WeightTotal(), ZoneID); // exclude download items! if (extraFee > System.Decimal.Zero) { freight += extraFee; } else if (freight > System.Decimal.Zero && extraFee > System.Decimal.Zero) { freight += extraFee; } if (freight < 0) { freight = 0; } thisMethod.Freight = freight; } bool include = !(this.ExcludeZeroFreightCosts == true && (thisMethod.Freight == decimal.Zero && !thisMethod.IsFree)); if (include) { availableShippingMethods.Add(thisMethod); } } } } return(availableShippingMethods); }
/// <summary> /// Represent the calculation for ShippingByTotal /// </summary> /// <returns>return collection of shipping method based on the computation of ShippingByTotalByPercent</returns> public override ShippingMethodCollection GetShippingMethods(int storeId) { ShippingMethodCollection availableShippingMethods = new ShippingMethodCollection(); bool shippingMethodToStateMapIsEmpty = Shipping.ShippingMethodToStateMapIsEmpty(); bool shippingMethodToCountryMapIsEmpty = Shipping.ShippingMethodToCountryMapIsEmpty(); decimal extraFee = AppLogic.AppConfigUSDecimal("ShippingHandlingExtraFee"); string shipsql = GenerateShippingMethodsQuery(storeId, false); decimal SubTotalWithoutDownload = this.Cart.SubTotal(true, false, false, false, true, false, 0, true); using (SqlConnection dbconn = new SqlConnection(DB.GetDBConn())) { dbconn.Open(); using (IDataReader reader = DB.GetRS(shipsql.ToString(), dbconn)) { while (reader.Read()) { ShippingMethod thisMethod = new ShippingMethod(); thisMethod.Id = DB.RSFieldInt(reader, "ShippingMethodID"); thisMethod.Name = DB.RSFieldByLocale(reader, "Name", ThisCustomer.LocaleSetting); thisMethod.IsFree = this.ShippingIsFreeIfIncludedInFreeList && Shipping.ShippingMethodIsInFreeList(thisMethod.Id); if (Cart.ShippingIsFree) { string FreeShippingMethodIDs = Shipping.GetFreeShippingMethodIDs(); if (CommonLogic.IntegerIsInIntegerList(thisMethod.Id, FreeShippingMethodIDs)) { thisMethod.Freight = 0.0M; thisMethod.ShippingIsFree = true; } } if (thisMethod.IsFree) { thisMethod.Freight = decimal.Zero; } else { decimal freight = Shipping.GetShipByTotalCharge(thisMethod.Id, SubTotalWithoutDownload); // exclude download items! if (extraFee > System.Decimal.Zero) { freight += extraFee; } else if (freight > System.Decimal.Zero && extraFee > System.Decimal.Zero) { freight += extraFee; } if (freight < 0) { freight = 0; } thisMethod.Freight = freight; } bool include = !(this.ExcludeZeroFreightCosts == true && (thisMethod.Freight == decimal.Zero && !thisMethod.IsFree)); if (include) { availableShippingMethods.Add(thisMethod); } } } } return(availableShippingMethods); }