FedEx Shipping - Destination Type Issue

  • Posts: 106
  • Thank you received: 5
  • Hikaserial Standard Hikashop Business
9 years 6 months ago #202242

-- HikaShop version -- : 2.4.0
-- Joomla version -- : 3.4.1
-- PHP version -- : 5.4.39

I have the FedEx destination type set to Auto-determination, so I would expect that it would show the rates only appropriate for the customer's shipping address (commercial or residential). No matter the type of the customer's address, I see all FedEx shipping options. With a commercial address, I should not see the Ground (Home Delivery) rate. With a residential address, I should not see the regular Ground option (which is cheaper). It should be the Ground (Home Delivery) option.

Edit:
I would also like clarification on how the determination between commercial and residential address works.

Last edit: 9 years 6 months ago by gpraceman.
The following user(s) said Thank You: Mohamed Thelji

Please Log in or Create an account to join the conversation.

  • Posts: 12953
  • Thank you received: 1778
9 years 6 months ago #202268

Hello,

1.
Sorry, on the version that I gave you on our previous thread I accidentally replaced the name of the ETA format option, to Destination Type, here is the last FedEx version.

2.

I would also like clarification on how the determination between commercial and residential address works.

That option only allow us to send as it's said on their documentation, a "residential" parameter set to :
- True
If the "Destination Type" option is set to Residential
- False
If the "Destination Type" option is set to Commercial
OR
If the "Destination Type" option is set to Auto in the case of the FedEx Ground service request, it will be set to YES for other services.

So even if you set it to Auto, the FedEx won't determine your destination type regarding your customer address, but regarding how you have set that option.
Also, note that the FedEx shipping methods wasn't originally developed by us and that I'm maintaining it so that customers can always use it, so I thank you for your feedback which are helping me to fix the FedEx shipping plugin and make it better for every other customers.

Attachments:
Last edit: 9 years 6 months ago by Mohamed Thelji.

Please Log in or Create an account to join the conversation.

  • Posts: 106
  • Thank you received: 5
  • Hikaserial Standard Hikashop Business
9 years 6 months ago #202357

Looking into the code in that latest update, the destination type setting currently has no effect, as that section of code is commented out. If it wasn't commented out and destination type is set to auto, then it uses the address_company field to determine if it is residential or not. Well, such a determination is problematic. Just because a customer enters a company name, doesn't mean that it is a commercial address. If it is a home-based business, like my own, then it should not get the commercial rate.

/*$data['destType']='';
		if(@$rate->shipping_params->destination_type=='res'){
			$data['destType']='<ResidentialAddressIndicator/>';
		}
		if(@$rate->shipping_params->destination_type=='auto' && !isset($order->shipping_address->address_company)){
			$data['destType']='<ResidentialAddressIndicator/>';
		}*/

I would recommend adding a new address field, like "address_type", where the customer must select whether their address is Commercial or Residential and use that with the FedEx plugin, not the address_company field. Then those with home-based businesses will not get displayed the less expensive commercial rates.

With that code commented out, only commercial rates are being returned. That doesn't, however, explain why the Ground (Home Delivery) option is being displayed along with commercial rates. That will take some more digging into the code.

Please Log in or Create an account to join the conversation.

  • Posts: 106
  • Thank you received: 5
  • Hikaserial Standard Hikashop Business
9 years 6 months ago #202371

I've made some changes to the fedex.php file to fix these problems. It also sorts the delivery methods in ascending order by rate. My changes are annotated by my username. For this, I did add a new address field that I called "address_type" with a single dropdown. The customer must select if the address is commercial or residential. This is used instead of the address_company field, for the reasons stated previously.

I still have the issue that I reported in another thread of the cheapest shipping option, among the shipping plugins being used, is not being selected.

Edit: I did add a sort function at the end of the file, that I forgot to annotate. I copied that from the USPS plugin.

Attachments:
Last edit: 9 years 6 months ago by gpraceman.

Please Log in or Create an account to join the conversation.

  • Posts: 12953
  • Thank you received: 1778
9 years 6 months ago #202410

Hello,
The FedEx code that you showed me was the old way to define the Residential parameter, here is the code which is setting that parameter :

if(@$rate->shipping_params->destination_type=='res'){
	$recipient['Address']['Residential'] = true;
}
if(@$rate->shipping_params->destination_type=='com' || (@$rate->shipping_params->destination_type=='auto' && $v == 'FEDEX_GROUND')){
	$recipient['Address']['Residential'] = false;
}
but I'm glad that you succeed to edit the FedEx shipping plugin so that it works as you want.

Also, regarding the other issue, I'm currently testing it on my end :).

Please Log in or Create an account to join the conversation.

  • Posts: 106
  • Thank you received: 5
  • Hikaserial Standard Hikashop Business
9 years 6 months ago #202462

Mohamed Thelji wrote: Hello,
The FedEx code that you showed me was the old way to define the Residential parameter, here is the code which is setting that parameter :

if(@$rate->shipping_params->destination_type=='res'){
	$recipient['Address']['Residential'] = true;
}
if(@$rate->shipping_params->destination_type=='com' || (@$rate->shipping_params->destination_type=='auto' && $v == 'FEDEX_GROUND')){
	$recipient['Address']['Residential'] = false;
}

I did see this code. However, it wasn't working, since FEDEX_GROUND was always in the list of delivery methods, whether it was a residential address or not. So, the less expensive commercial rate was always being returned. I added a bit of code at the beginning of that function to skip past the ground method that didn't apply to the address type.

Please Log in or Create an account to join the conversation.

  • Posts: 106
  • Thank you received: 5
  • Hikaserial Standard Hikashop Business
9 years 5 months ago #204415

I just upgraded our test site to 2.5.0 and am still having several issues with this plugin.

1) Both FedEx Ground (Home Delivery) and FedEx Ground rates are being shown. FedEx Ground (Home Delivery) rates should only be displayed to residential delivery addresses. FedEx Ground rates should only be shown to commercial delivery addresses. A residential customer will, of course, select the cheaper of the two, which is FedEx Ground, even though they are not eligible for that rate. Maybe this situation is why I am seeing "The FedEx request failed with the message : Customer not eligible for service." error message.

2) I still get "The FedEx request failed with the message : Service is not allowed." error messages.

3) Delivery options are not sorted by rate.

I would recommend that you take a look at the changes that I made to the plugin, which is attached, as it addresses all of these issues. All of my changes are annotated.

If need be, I can give you access to our test site for troubleshooting purposes.

Attachments:
Last edit: 9 years 5 months ago by gpraceman.

Please Log in or Create an account to join the conversation.

  • Posts: 12953
  • Thank you received: 1778
9 years 5 months ago #204576

Hello,
1.
In that case the solution will probably be to add that kind of code :

if($v == 'GROUND_HOME_DELIVERY' && !$recipient['Address']['Residential'])
	continue;
Just after these lines :
if(@$rate->shipping_params->destination_type=='res'){
	$recipient['Address']['Residential'] = true;
}
if(@$rate->shipping_params->destination_type=='com' || (@$rate->shipping_params->destination_type=='auto' && $v == 'FEDEX_GROUND')){
	$recipient['Address']['Residential'] = false;
}
2.
That issue is coming from the fact that some shipping services aren't compatible/available with your current FedEx shipping configuration/shipping address/.. to solve it and to use every services, you'll have to create multiple FedEx shipping methods with different configurations for each cases.
3.
There is actually no option to do that but, sorting FedEx shipping rates will be easy to do by sorting the "$shipment" variable through the "_FEDEXrequestMethods" function.

Please Log in or Create an account to join the conversation.

  • Posts: 106
  • Thank you received: 5
  • Hikaserial Standard Hikashop Business
9 years 5 months ago #204620

Mohamed Thelji wrote: 1.
In that case the solution will probably be to add that kind of code :

if($v == 'GROUND_HOME_DELIVERY' && !$recipient['Address']['Residential'])
	continue;
Just after these lines :
if(@$rate->shipping_params->destination_type=='res'){
	$recipient['Address']['Residential'] = true;
}
if(@$rate->shipping_params->destination_type=='com' || (@$rate->shipping_params->destination_type=='auto' && $v == 'FEDEX_GROUND')){
	$recipient['Address']['Residential'] = false;
}

The problem with that is the FedEx Ground option is always present, as I have customers that ship to a residential address and others that ship to a commercial address. So, I have FedEx Ground and FedEx Ground (Home Delivery) methods enabled via the backend. The above code always ends up with residential set to false. The FedEx plugin should be able to reliably determine if the recipient address is residential or commercial. That should be based on the information provided by the customer. To fix this issue, I created a required custom address field named "Address Type" where the customer must select if their address is commercial or residential. You can see this in the edited plugin that I posted. This is how the FedEx plugin that I used with my old Virtuemart shop worked.

From looking at the UPS plugin (line 527), it uses the address_company field to help in determining if an address is residential or not. There are problems with using that field, which I mentioned earlier, but at least that plugin tries to make that determination. So, why can't the FedEx plugin be changed to do so?

Mohamed Thelji wrote: 2.
That issue is coming from the fact that some shipping services aren't compatible/available with your current FedEx shipping configuration/shipping address/.. to solve it and to use every services, you'll have to create multiple FedEx shipping methods with different configurations for each cases.


This chunk of code should actually be ignoring that message, but isn't.
if(!$notif && !empty($response->Notifications->Message) && $response->Notifications->Message != 'Service is not allowed') {
	$app = JFactory::getApplication();
	$app->enqueueMessage('The FedEx request failed with the message : ' . $response->Notifications->Message);
}

I had to modify this code to get the "Service is not allowed" and "Customer not eligible for service" messages to be ignored.
if(!$notif && !empty($response->Notifications->Message) && strpos($response->Notifications->Message, 'not allowed') === false && strpos($response->Notifications->Message, 'not eligible') === false) {
	$app = JFactory::getApplication();
	$app->enqueueMessage('The FedEx request failed with the message : ' . $response->Notifications->Message);
}

It seems strange to me that I would have to develop multiple FedEx shipping methods with different configurations, just to be able to ship to residential vs. commercial addresses. The plugin should be able to handle either scenario.

Mohamed Thelji wrote: 3.
There is actually no option to do that but, sorting FedEx shipping rates will be easy to do by sorting the "$shipment" variable through the "_FEDEXrequestMethods" function.

OK, so please do so. It seems strange to have a shipping plugin that doesn't automatically sort the rates. The customer should not have to pick through the list to see what the cheapest option is. It should be readily apparent.

Last edit: 9 years 5 months ago by gpraceman.

Please Log in or Create an account to join the conversation.

  • Posts: 12953
  • Thank you received: 1778
9 years 5 months ago #204826

Hello,
1.

From looking at the UPS plugin (line 527), it uses the address_company field to help in determining if an address is residential or not. There are problems with using that field, which I mentioned earlier, but at least that plugin tries to make that determination. So, why can't the FedEx plugin be changed to do so?

As I already told you the FedEx shipping method wasn't originally developed by us, and I'm just maintaining it, but you're totally right, the address type determination should be based on the "address_company" !

2.
I know but some services are not compatible for example with the way you have the the "Packaging type" option for example, so the easier way will be to create different instance of that shipping method.

3.
Ok I just added it on the TODO list regarding the FedEx shipping method :).

Thanks for your feedback.

Please Log in or Create an account to join the conversation.

  • Posts: 106
  • Thank you received: 5
  • Hikaserial Standard Hikashop Business
9 years 5 months ago #205080

Mohamed Thelji wrote: 1.
As I already told you the FedEx shipping method wasn't originally developed by us, and I'm just maintaining it, but you're totally right, the address type determination should be based on the "address_company" !


As I tried to point out earlier, there's a big issue with using "address_company" to make that determination. A home-based business (like my own) will have a company name, but shipping should be residential not commercial. Why not ask the customer if the address is commercial or residential? That is why I made a new address custom field and use that with the FedEx plugin, not the address_company field. That is copied from the implementation of the FedEx plugin for Virtuemart on that issue.

Mohamed Thelji wrote: 2.
I know but some services are not compatible for example with the way you have the the "Packaging type" option for example, so the easier way will be to create different instance of that shipping method.

I really don't follow you on how that could be implemented to meet my needs for commerical vs. residential delivery addresses.

Mohamed Thelji wrote: 3.
Ok I just added it on the TODO list regarding the FedEx shipping method :).

Thanks

Please Log in or Create an account to join the conversation.

  • Posts: 12953
  • Thank you received: 1778
9 years 5 months ago #205127

Hello,
1.
That option was already developed by a third party developer, but the best case for us will be to use the "address_company" field like we have done on the UPS shipping plugin.
The "address_company" is a default address custom field, we don't want customers to be forced to create a new custom field to use that shipping plugin.
2.
Some shipping configurations are compatible with some shipping destination/order weight/... and some are not, so you can use the FedEx option restriction to restrict that shipping method to only be used during "compatible cases".

Please Log in or Create an account to join the conversation.

  • Posts: 106
  • Thank you received: 5
  • Hikaserial Standard Hikashop Business
9 years 5 months ago #205197

Mohamed Thelji wrote: 1.
That option was already developed by a third party developer, but the best case for us will be to use the "address_company" field like we have done on the UPS shipping plugin.
The "address_company" is a default address custom field, we don't want customers to be forced to create a new custom field to use that shipping plugin.

I can understand that concern. However, it would be great if you give the shop owner the choice between using the address_company field or a custom field that they can specify for the plugin to use.

Mohamed Thelji wrote: 2.
Some shipping configurations are compatible with some shipping destination/order weight/... and some are not, so you can use the FedEx option restriction to restrict that shipping method to only be used during "compatible cases".

Unfortunately, the error message is not specific enough on what the root problem is. So, it would be hard to do so. As far as I know, adding a restriction will affect all shipping methods, not any single one that the issue might be with.

Anyways, with those cases, FedEx will not return a rate for those applicable shipping methods. The customer only see the rates that are applicable. So, then it is just a matter of suppressing the error message, as it is really not something that the customer needs to be concerned with.

Last edit: 9 years 5 months ago by gpraceman.

Please Log in or Create an account to join the conversation.

  • Posts: 12953
  • Thank you received: 1778
9 years 5 months ago #205262

Ok then I'll also add it on our Todo list an try to error messages.

it would be hard to do so. As far as I know, adding a restriction will affect all shipping methods,

Note that really, it will only affect the shipping services of your shipping method, but note that you can create different shipping methods (instance of the FedEx shipping plugin) with different shipping services on it (FedEx services like FedEx Ground) with different shipping restriction options.

Please Log in or Create an account to join the conversation.

Time to create page: 0.081 seconds
Powered by Kunena Forum