Setting up and configuring Fedex shipping

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

I'm attempting to set up a fedex account, I've received my developer test key etc. and plugged all my account details into the settings under Shipping Rate Computation. All should be fine, but when testing Estimate Shipping or going through the checkout process when I get to the shipping part, I receive this error: “There are no valid services available. (code: 556)”

I've set the shipping origin and destination to valid addresses/zip codes in the US and am still having no joy with it.

Also, it seems that when I try and switch it to an international destination (A valid address/postcode in the UK), it doesn't seem to support it and I get this message: "The length of the destination state or province exceeds the limit of 2 characters."

Any assistance would be much appreciated!

Many thanks
13 years ago
Ok, I figured out what's happening with my first problem, even though I was setting the shipment from US to US, because the shop's primary currency was GBP, we were getting the error. Changing this to USD resolved it.

I've talked to Fedex support and they advised that the currency code for Fedex for UK is UKL, not GBP? I know that Fedex web services doesn't support UK to UK, but International shipping from UK would be very useful for us.

Again, any help would be appreciated, thanks.
13 years ago
The errors "The length of the destination state or province exceeds the limit of 2 characters." and "The length of the origin state or province exceeds the limit of 2 characters." are caused when the state code is not two characters in either the customer selected state/province (from the Nop_StateProvince table) or the FedEx configuration "Shipping origin. State code" setting. The following changes shall allow you to use FedEx to ship to/from the United Kingdom. Note, the following line numbers refer to 1.90.

Edit file: Shipping\Nop.Shipping.FedEx\FedExComputationMethod.cs

Change line 126 (in SetDestination() method) from:
if (ShipmentPackage.ShippingAddress.StateProvince != null)

to:
if (ShipmentPackage.ShippingAddress.StateProvince != null && IncludeStateProvidenceCode(ShipmentPackage.ShippingAddress.Country.TwoLetterIsoCode))

Change method SetOrigin() from:
private void SetOrigin(RateRequest request)
{
    request.RequestedShipment.Shipper = new Party();
    request.RequestedShipment.Shipper.Address = new Address();
    request.RequestedShipment.Shipper.Address.StreetLines = new string[1] { IoC.Resolve<ISettingManager>().GetSettingValue("ShippingRateComputationMethod.FedEx.ShippingOrigin.Street") };
    request.RequestedShipment.Shipper.Address.City = IoC.Resolve<ISettingManager>().GetSettingValue("ShippingRateComputationMethod.FedEx.ShippingOrigin.City");
    request.RequestedShipment.Shipper.Address.StateOrProvinceCode = IoC.Resolve<ISettingManager>().GetSettingValue("ShippingRateComputationMethod.FedEx.ShippingOrigin.StateOrProvinceCode");
    request.RequestedShipment.Shipper.Address.PostalCode = IoC.Resolve<ISettingManager>().GetSettingValue("ShippingRateComputationMethod.FedEx.ShippingOrigin.PostalCode");
    request.RequestedShipment.Shipper.Address.CountryCode = IoC.Resolve<ISettingManager>().GetSettingValue("ShippingRateComputationMethod.FedEx.ShippingOrigin.CountryCode");
}

to:
private void SetOrigin(RateRequest request)
{
    request.RequestedShipment.Shipper = new Party();
    request.RequestedShipment.Shipper.Address = new Address();
    request.RequestedShipment.Shipper.Address.StreetLines = new string[1] { IoC.Resolve<ISettingManager>().GetSettingValue("ShippingRateComputationMethod.FedEx.ShippingOrigin.Street") };
    request.RequestedShipment.Shipper.Address.City = IoC.Resolve<ISettingManager>().GetSettingValue("ShippingRateComputationMethod.FedEx.ShippingOrigin.City");
    string countryCode = IoC.Resolve<ISettingManager>().GetSettingValue("ShippingRateComputationMethod.FedEx.ShippingOrigin.CountryCode");
    if (IncludeStateProvidenceCode(countryCode))
    {
        request.RequestedShipment.Shipper.Address.StateOrProvinceCode = IoC.Resolve<ISettingManager>().GetSettingValue("ShippingRateComputationMethod.FedEx.ShippingOrigin.StateOrProvinceCode");
    }
    request.RequestedShipment.Shipper.Address.PostalCode = IoC.Resolve<ISettingManager>().GetSettingValue("ShippingRateComputationMethod.FedEx.ShippingOrigin.PostalCode");
    request.RequestedShipment.Shipper.Address.CountryCode = countryCode;
}

Add the following method:
private bool IncludeStateProvidenceCode(string countryCode)
{
    return (countryCode.Equals("US", StringComparison.InvariantCultureIgnoreCase) ||
            countryCode.Equals("CA", StringComparison.InvariantCultureIgnoreCase));
}

These changes will cause the rate request to include the state code only if it is required (when the country is US or CA).

---

To ensure the store owner only sets two characters for the state code in the FedEx configuration, edit file Administration\Shipping\FedExConfigure\ConfigureShipping.ascx.cs

Change line 101 from:
this.SettingManager.SetParam("ShippingRateComputationMethod.FedEx.ShippingOrigin.StateOrProvinceCode", txtShippingOriginStateOrProvinceCode.Text);

to:
string stateCode = CommonHelper.EnsureMaximumLength(txtShippingOriginStateOrProvinceCode.Text, 2);
this.SettingManager.SetParam("ShippingRateComputationMethod.FedEx.ShippingOrigin.StateOrProvinceCode", stateCode);

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

Change line 102 from:
Shipping origin. State code:

to
Shipping origin. State code (2 characters):

Recompile the solution and copy the updated NopCommerceStore.dll and Nop.Shipping.FedEx.dll assemblies to the bin folder on your server and copy ConfigureShipping.ascx to the Administration\Shipping\FedExConfigure\ folder on your server.

.
13 years ago
Thanks alot for the reply, it is 1.9 that we're using. I've not actually really played much with the asp.net files so far, I take it that I'll need Visual Studio express, edit the files as you mention and recompile it in there? Our current site doesn't have all the source files included either, I've downloaded the file, but I'm not sure where I should place the contents of the \shipping\ source folder within the website, just in website\administration\shipping\ folder?

Thanks again
13 years ago
Below are the updated assemblies and control that need to be updated on your server to use the above bug fix -see the enclosed README.txt file for install instructions. You can use them instead of recompiling the solution.

http://www.mediafire.com/file/vek811pm31838nx/fedex_update.zip (for nopCommerce 1.90)

---
To answer your questions:
You would need the source version of nopCommerce 1.90 and Visual Studio 2010 or Visual Web Developer 2010 Express to recompile the solution.  The \Shipping folder isn't required on the website -only when the solution is compiled. The Administration\Shipping\FedExConfigure\ folder is used to store the configuration template (the file you see when you edit the FedEx configuration in Administration > Configuration > Shipping > Shipping Rate Computation).

.
13 years ago
Thanks alot for your reply, that's fixed the error codes I was getting, I now have US to US and US to UK working fine (When the store primary currency is set to USD only, it will not work if the currency is GBP as fedex seems to use the country code UKL??).

I've been told by Fedex that the support UK to International through this service, however, when I set my origin shipping address to a location in the UK and try to raise a shipping quote for a US destination, I now get "Origin country is not serviced.".

Starting to tear my hair out with this, any suggestions?
13 years ago
Ok, have moved a little further, I can now get UK to International working (Changed country code from UK to GB), but now the only issue I am having is that for Fedex to work at all, the store needs to be set to USD as the primary store currency under Configuration > Location > Currency. Setting it to GBP gives the error code "There are no valid services available. (code: 556)" when getting a shipping quote.

Obviously as a UK store that operates in GBP, this isn't ideal, is there any way to fix this? I've been advised by Fedex that their currency code for web services for UK is UKL, not GBP. So I'm guessing that this is the problem...

As ever, any advice most welcome and appreciated. Thanks!
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.