Fedex Residential

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

I need help. I use Fedex as my carrier. And Fedex as my shipping rate computation method. Everything works great but...
Fedex calculates the shipping charge based on commercial adresses, most of my customer will provide residential addresses

of course Home Delivery is more expensive than commercial, and I lose money in every transaction.

I'm willing to pay a reasonable price to the programmer who will write a code for me and tell me in steps how to change that in my nop.
Can someone help me out?


Magdalena
14 years ago
The following changes will enable residential rates for the FedEx shipping rate computation method and allow you to set an additional fee for the rates (both configurable in Administration -uncheck the checkbox for commercial rates and use 0 for no additional fee).

Edit file: Shipping\Nop.Shipping.FedEx\FedExComputationMethod.cs and modify the SetDestination(...) function with the new lines in bold (starts at line #114):

private void SetDestination(RateRequest request, ShipmentPackage ShipmentPackage)
{
    request.RequestedShipment.Recipient = new Party();
    request.RequestedShipment.Recipient.Address = new Address();
    if (SettingManager.GetSettingValueBoolean("ShippingRateComputationMethod.FedEx.UseResidentialRates", false))
    {
        request.RequestedShipment.Recipient.Address.Residential = true;
        request.RequestedShipment.Recipient.Address.ResidentialSpecified = true;
    }

    request.RequestedShipment.Recipient.Address.StreetLines = new string[1] { "Recipient Address Line 1" };
    request.RequestedShipment.Recipient.Address.City = ShipmentPackage.ShippingAddress.City;
    if (ShipmentPackage.ShippingAddress.StateProvince != null)
    {
        request.RequestedShipment.Recipient.Address.StateOrProvinceCode = ShipmentPackage.ShippingAddress.StateProvince.Abbreviation;
    }
    else
    {
        request.RequestedShipment.Recipient.Address.StateOrProvinceCode = string.Empty;
    }
    request.RequestedShipment.Recipient.Address.PostalCode = ShipmentPackage.ShippingAddress.ZipPostalCode;
    request.RequestedShipment.Recipient.Address.CountryCode = ShipmentPackage.ShippingAddress.Country.TwoLetterISOCode;
}

With this change, you will no longer have "FEDEX GROUND" displayed as a shipping method as it is only for commercial addresses; instead you will have "GROUND HOME DELIVERY" which is for residential.

---

In the same file, to have an optional additional fee added to each rate, modify the ParseResponse(RateReply reply) function with the changes in bold (function starts at line #223):

private ShippingOptionCollection ParseResponse(RateReply reply)
{
    decimal additionalFee = SettingManager.GetSettingValueDecimalNative("ShippingRateComputationMethod.FedEx.AdditionalFee", 0);

    ShippingOptionCollection result = new ShippingOptionCollection();

    Debug.WriteLine("RateReply details:");
    Debug.WriteLine("**********************************************************");
    foreach (RateReplyDetail rateDetail in reply.RateReplyDetails)
    {
        Debug.WriteLine("ServiceType: " + rateDetail.ServiceType);
        for (int i = 0; i < rateDetail.RatedShipmentDetails.Length; i++)
        {
            RatedShipmentDetail shipmentDetail = rateDetail.RatedShipmentDetails[ i ];
            Debug.WriteLine("RateType : " + shipmentDetail.ShipmentRateDetail.RateType);
            Debug.WriteLine("Total Billing Weight : " + shipmentDetail.ShipmentRateDetail.TotalBillingWeight.Value);
            Debug.WriteLine("Total Base Charge : " + shipmentDetail.ShipmentRateDetail.TotalBaseCharge.Amount);
            Debug.WriteLine("Total Discount : " + shipmentDetail.ShipmentRateDetail.TotalFreightDiscounts.Amount);
            Debug.WriteLine("Total Surcharges : " + shipmentDetail.ShipmentRateDetail.TotalSurcharges.Amount);
            Debug.WriteLine("Net Charge : " + shipmentDetail.ShipmentRateDetail.TotalNetCharge.Amount);
            Debug.WriteLine("*********");

            //take first one
            if (i == 0)
            {
                ShippingOption shippingOption = new ShippingOption();
                string userFriendlyServiceType = GetUserFriendlyEnum(rateDetail.ServiceType.ToString());
                shippingOption.Name = userFriendlyServiceType;
                shippingOption.Rate = shipmentDetail.ShipmentRateDetail.TotalNetCharge.Amount + additionalFee;
                result.Add(shippingOption);
            }
        }
        Debug.WriteLine("**********************************************************");
    }

    return result;
}

---

To make residential rates and additional fees configurable in the FedEx configuration template in Administration, edit file: Administration\Shipping\FedExConfigure\ConfigureShipping.ascx

Add the following at line #57
<tr>
    <td class="adminTitle">
        Use Residential Rates:
    </td>
    <td class="adminData">
        <asp:CheckBox ID="cbUseResidentialRates" runat="server">
        </asp:CheckBox>
    </td>
</tr>
<tr>
    <td class="adminTitle">
        Additional Fee [<%=CurrencyManager.PrimaryStoreCurrency.CurrencyCode%>]:
    </td>
    <td class="adminData">
        <nopCommerce:DecimalTextBox runat="server" ID="txtAdditionalFee" Value="0"
            RequiredErrorMessage="Value is required" MinimumValue="0" MaximumValue="999999"
            RangeErrorMessage="The value must be from 0 to 999999" CssClass="adminInput">
        </nopCommerce:DecimalTextBox>
    </td>
</tr>

---

Edit file: Administration\Shipping\FedExConfigure\ConfigureShipping.ascx.cs

Add the following to the BindData() function:
txtAdditionalFee.Value = SettingManager.GetSettingValueDecimalNative("ShippingRateComputationMethod.FedEx.AdditionalFee");
cbUseResidentialRates.Checked = SettingManager.GetSettingValueBoolean("ShippingRateComputationMethod.FedEx.UseResidentialRates");


Add the following to the Save() function:
SettingManager.SetParam("ShippingRateComputationMethod.FedEx.AdditionalFee", txtAdditionalFee.Value.ToString());
SettingManager.SetParam("ShippingRateComputationMethod.FedEx.UseResidentialRates", cbUseResidentialRates.Checked.ToString());

This is for version 1.40 and you will need to recompile the solution.

.


*Post updated to include configuration options*
14 years ago
my problem is still not solved :(

is anyone interested in making changes for me? I'll pay.

thank you.

Magdalena
13 years ago
Is there a way of doing it with version 1.7? I tried these edits but they do not add the fee to the shipping charges.
13 years ago
edcorusa wrote:
Is there a way of doing it with version 1.7? I tried these edits but they do not add the fee to the shipping charges.

Just go to FedEx configuration page and ensure that 'Use Residential Rates' is checked
13 years ago
Thank you, but I was more interested in the additional fee. FedEx seems to be charging the shipper more than they qote prices for these days. I wish to add an additional fee for make up for pickup charges and other fees that FedEx is adding on to are bill.
13 years ago
FedEx Additional Fee for 1.80 (should also work for 1.70, but is untested):

Download includes the modified files (see README.txt):
http://www.mediafire.com/file/d2vdjpf230ff3t6/FedEx_Additional_Fee.zip

.
11 years ago
Is there a version of this for 2.8?
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.