private decimal?GetRate(decimal subTotal, decimal weight, int shippingMethodId, int storeId, int countryId, string zip)
        {
            decimal?shippingTotal = null;

            var shippingByWeightRecord = _shippingByWeightService.FindRecord(shippingMethodId, storeId, countryId, weight, zip);

            if (shippingByWeightRecord == null)
            {
                if (_shippingByWeightSettings.LimitMethodsToCreated)
                {
                    return(null);
                }
                else
                {
                    return(decimal.Zero);
                }
            }

            if (shippingByWeightRecord.UsePercentage && shippingByWeightRecord.ShippingChargePercentage <= decimal.Zero)
            {
                return(decimal.Zero);
            }
            if (!shippingByWeightRecord.UsePercentage && shippingByWeightRecord.ShippingChargeAmount <= decimal.Zero)
            {
                return(decimal.Zero);
            }

            if (shippingByWeightRecord.UsePercentage)
            {
                shippingTotal = Math.Round((decimal)((((float)subTotal) * ((float)shippingByWeightRecord.ShippingChargePercentage)) / 100f), 2);
            }
            else
            {
                if (_shippingByWeightSettings.CalculatePerWeightUnit)
                {
                    shippingTotal = shippingByWeightRecord.ShippingChargeAmount * weight;
                }
                else
                {
                    shippingTotal = shippingByWeightRecord.ShippingChargeAmount;
                }
            }

            if (shippingTotal < decimal.Zero)
            {
                shippingTotal = decimal.Zero;
            }

            return(shippingTotal);
        }
        /// <summary>
        /// Get rate by weight
        /// </summary>
        /// <param name="subTotal">Subtotal</param>
        /// <param name="weight">Weight</param>
        /// <param name="shippingMethodId">Shipping method ID</param>
        /// <param name="storeId">Store ID</param>
        /// <param name="warehouseId">Warehouse ID</param>
        /// <param name="countryId">Country ID</param>
        /// <param name="stateProvinceId">State/Province ID</param>
        /// <param name="zip">Zip code</param>
        /// <returns>Rate</returns>
        private decimal?GetRate(decimal subTotal, decimal weight, int shippingMethodId,
                                int storeId, int warehouseId, int countryId, int stateProvinceId, string zip)
        {
            var shippingByWeightRecord = _shippingByWeightService.FindRecord(shippingMethodId, storeId, warehouseId, countryId, stateProvinceId, zip, weight);

            if (shippingByWeightRecord == null)
            {
                if (_fixedOrByWeightSettings.LimitMethodsToCreated)
                {
                    return(null);
                }

                return(decimal.Zero);
            }

            //additional fixed cost
            var shippingTotal = shippingByWeightRecord.AdditionalFixedCost;

            //charge amount per weight unit
            if (shippingByWeightRecord.RatePerWeightUnit > decimal.Zero)
            {
                var weightRate = Math.Max(weight - shippingByWeightRecord.LowerWeightLimit, decimal.Zero);
                shippingTotal += shippingByWeightRecord.RatePerWeightUnit * weightRate;
            }

            //percentage rate of subtotal
            if (shippingByWeightRecord.PercentageRateOfSubtotal > decimal.Zero)
            {
                shippingTotal += Math.Round((decimal)((((float)subTotal) * ((float)shippingByWeightRecord.PercentageRateOfSubtotal)) / 100f), 2);
            }

            return(Math.Max(shippingTotal, decimal.Zero));
        }