| Project: | Ubercart |
| Version: | 6.x-2.x-dev |
| Component: | Shipping |
| Category: | bug report |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | needs review |
Issue Summary
Steps to reproduce:
1. Set up USPS as a shipping option
2. Create an order with a shipping address in Puerto Rico or Guam
3. Calculate shipping rates
ACTUAL RESULT:
AJAX request fails with 500 internal server error
EXPECTED RESULT:
shipping results show up
checking out the code, this seems to be hitting an unhandled code path:
ubercart/shipping/uc_usps/uc_usps.module, lines 374 - 381:
if (strpos($method['id'], 'intl') && ($destination->country != 840)) {
// Build XML for international rate request
$request = uc_usps_intl_rate_request($ship_packages, $orig, $destination);
}
elseif ($destination->country == 840) {
// Build XML for domestic rate request
$request = uc_usps_rate_request($ship_packages, $orig, $destination);
}
note that 840 = country ID of USA
so in our scenario, the shipping $method['id'] is usps, and the country ID is (E.g.) 630 (Puerto Rico), so neither the first nor second branches match, the $request variable is never assigned and the HTTP request for shipping quotes fails.
Comments
#1
Here is one possible solution - in an additional else branch, if the $method['id'] is not 'intl', we default to using the "domestic" rate request.
#2
The last submitted patch, 1901296-ubercart-usps-shipping-to-us_territories.patch, failed testing.
#3
Whether to use US or International quotes is already decided by Rules, so I think we can remove the country test here.
#4
I won't be able to check on this for a while, but I'm pretty sure that for USPS you should be using country = US and selecting Puerto Rico as the *zone*, not the country.
#5
Double post ...
#6
Oh, and the patch in #3 reverts the code to how it used to be two years ago. The check for country was put in there deliberately as part of commit 5aa9d168. I don't remember right now exactly why it was added, but it was certainly done to address a bug/problem.
Edit: I previously referred to the wrong patch #. Fixed now.
#7
Maybe the solution is to remove Puerto Rico and Guam from the Country list on the Shipping Address form, thereby forcing selection of Country = US and Puerto Rico or Guam as the State/Province ?
#8
Yes, that's what I've done in the past.