Changing default shipping calculation by weight formula method

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
8 years ago
Hi there,

does anyone know how to do this?
I wish to change the default formula from

[additional fixed cost] + ([order total weight] - [lower weight limit]) * [rate per weight unit] + [order subtotal] * [charge percentage]

to

[charge percentage] * ([additional fixed cost] + ([order total weight] - [lower weight limit]) * [rate per weight unit]) + [order subtotal]


Thanks
Kevin
8 years ago
[email protected] wrote:
Hi there,

does anyone know how to do this?
I wish to change the default formula from

[additional fixed cost] + ([order total weight] - [lower weight limit]) * [rate per weight unit] + [order subtotal] * [charge percentage]

to

[charge percentage] * ([additional fixed cost] + ([order total weight] - [lower weight limit]) * [rate per weight unit]) + [order subtotal]


Thanks
Kevin


You should apply this in the Nop.Plugin.Shipping.ByWeight  plugin  

File: \Plugins\Nop.Plugin.Shipping.ByWeight\ByWeightShippingComputationMethod.cs

Action:

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 (_shippingByWeightSettings.LimitMethodsToCreated)
                    return null;
                
                return decimal.Zero;
            }

            //additional fixed cost
            decimal shippingTotal = shippingByWeightRecord.AdditionalFixedCost;
            //charge amount per weight unit
            if (shippingByWeightRecord.RatePerWeightUnit > decimal.Zero)
            {
                var weightRate = weight - shippingByWeightRecord.LowerWeightLimit;
                if (weightRate < decimal.Zero)
                    weightRate = 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);
            }

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


Modify above action according to your desired.
8 years ago
Thanks sohel
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.