Page 1 of 1

R6 ship method handling fee charged even shipping is zero

Posted: Fri Dec 20, 2013 8:01 am
by AbleMods
Just wanting to confirm a (very rare) bug I found in ship rate calculation. Here are the steps to reproduce:

Create a product. Give it a price of $ 30.00.
Create a product coupon. Make it give 100% discount, apply to a specific product (the one you just created), all groups etc.
Create a vary-by-cost shipping method. Make it charge 10% for any range of cost. Set it to charge a $ 1.00 handling fee.

Now try to buy the product. In checkout, you would expect shipping to come back as $ 4.00. This is comprised of $ 3.00 for the 10% cost and the $ 1.00 fee. The system correctly calculates $ 4.00. All is well.

Now apply your free product coupon.

Shipping goes to $ 1.00. It should go to $ 0.00 since there is no longer a product charge. It's still charging the fee even though the rate results in zero.

I believe the solution (requires full source code) is to modify /Shipping/ShipMethod.cs in the GetShipRateQuote() method. Near the end of the method, add a statement to test if minimum purchase is specified BEFORE applying the handling fee to the rate being returned.

Code: Select all

            // ADD ADDITIONAL SURCHARGE DEFINED FOR THIS SHIP METHOD
            // BEGIN MOD: AbleMods.com
            // DATE:  12/20/2013
            // only add surcharge (fee) if shipment meets minimum purchase requirement of this ship method
            if (this.MinPurchase > 0 && shipment.GetItems().TotalProductPrice() > 0)
            {
                decimal surchargeAmount;
                if (AlwaysConvert.ToBool(this.SurchargeIsPercent))
                    surchargeAmount = Math.Round(((decimal)quote.Rate / 100) * (decimal)this.Surcharge, 2);
                else surchargeAmount = this.Surcharge;
                if (this.SurchargeIsVisible)
                    quote.Surcharge = surchargeAmount;
                else quote.Rate += surchargeAmount;
            }

            // END MOD: AbleMods.com
            return quote;

Re: R6 ship method handling fee charged even shipping is zero

Posted: Fri Dec 20, 2013 9:04 am
by Katie
Shipping goes to $ 1.00. It should go to $ 0.00 since there is no longer a product charge
I believe the handling charge is kept separate of any calculated shipping cost. In other words, there is nothing in the code to remove the handling charge if the shipping cost ends up being 0. So, I don't think this is a bug. Like you said, this is a probably a rare situation, so a little custom code tweak should take care of this.