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.
Comment | File | Size | Author |
---|---|---|---|
#3 | 1901296-usps-territories.patch | 786 bytes | longwave |
#1 | 1901296-ubercart-usps-shipping-to-us_territories.patch | 700 bytes | benjaminbradley |
Comments
Comment #1
benjaminbradley CreditAttribution: benjaminbradley commentedHere is one possible solution - in an additional else branch, if the $method['id'] is not 'intl', we default to using the "domestic" rate request.
Comment #3
longwaveWhether to use US or International quotes is already decided by Rules, so I think we can remove the country test here.
Comment #4
TR CreditAttribution: TR commentedI 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.
Comment #5
TR CreditAttribution: TR commentedDouble post ...
Comment #6
TR CreditAttribution: TR commentedOh, 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.
Comment #7
benjaminbradley CreditAttribution: benjaminbradley commentedMaybe 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 ?
Comment #8
TR CreditAttribution: TR commentedYes, that's what I've done in the past.
Comment #9
benjaminbradley CreditAttribution: benjaminbradley commentedThis problem no longer occurs with Ubercart 6.x-2.4 and the current USPS shipping estimates API. Shipping estimates are successfully returned when selecting Country = USA and State/Province = Puerto Rico or Guam.