I'm getting a "Invalid option selected. Recalculate shipping quotes to continue." error in checkout when trying to process an order with shipping to Belgium. Domestic orders seem to work without error. I tried a delivery address in Sweden and that worked fine, too. The error is being caught at line 895 in uc_quote.module:
if ($predicate && ca_evaluate_conditions($predicate, $arguments)) {
$quote_data = uc_quote_action_get_quote($arg1, $method, $user);
}
if (!isset($quote_data[$quote_option[1]])) {
drupal_set_message(t('Invalid option selected. Recalculate shipping quotes to continue.'), 'error');
return FALSE;
}
I added some debugging messages to give me more info:
if (!isset($quote_data[$quote_option[1]])) {
drupal_set_message(t('Invalid option selected. Recalculate shipping quotes to continue.'), 'error');
drupal_set_message('Chosen quote method:<pre>'. print_r($method, TRUE) .'</pre>');
drupal_set_message('Chosen quote data:<pre>'. print_r($quote_option[1], TRUE) . " " . print_r($quote_data, TRUE) .'</pre>');
return FALSE;
}
Here's the error output:
Invalid option selected. Recalculate shipping quotes to continue.
Chosen quote method:
Array
(
[id] => usps_intl
[module] => uc_usps
[title] => U.S. Postal Service (Intl., Parcel)
[quote] => Array
(
[type] => small_package
[callback] => uc_usps_quote
[accessorials] => Array
(
[15] => First Class Mail International Package
[2] => Priority Mail International
[16] => Priority Mail International Small Flat-Rate Box
[9] => Priority Mail International Regular/Medium Flat-Rate Box
[11] => Priority Mail International Large Flat-Rate Box
[4] => Global Express Guaranteed
[6] => Global Express Guaranteed Non-Document Rectangular
[7] => Global Express Guaranteed Non-Document Non-Rectangular
[1] => Express Mail International (EMS)
)
)
[enabled] => 1
[weight] => 0
)
Chosen quote data:
15 Array
(
)
I can confirm that uc_quote_action_get_quote() is being called, but the returned $quote_data array is empty. This is for first class shipping (15), but I tried priority mail (2) and that failed, too. Is there something else I can look at to debug this further?
Comment | File | Size | Author |
---|---|---|---|
#19 | 1139338-usps-validation.patch | 941 bytes | longwave |
#16 | 1139338-16-uc_usps-address_zone_validation-15.patch | 837 bytes | j0rd |
#14 | uc_usps-address_zone_validation-14.patch | 814 bytes | peachykeen |
#12 | uc_usps-address_zone_validation.patch | 1.05 KB | peachykeen |
#8 | uc_usps-address_zone_validation-1139338-8.patch | 1.15 KB | Timon Davis |
Comments
Comment #1
sah62 CreditAttribution: sah62 commentedHmm, this is strange - it just started working without any code changes. Could the issue be with the USPS' online quote system not returning a quote?
Comment #2
sah62 CreditAttribution: sah62 commented...and now it's acting up again. This is strange!
Comment #3
TR CreditAttribution: TR commentedPlease post the USPS XML Request/Response - you can see it by turning on the debug option at admin/store/settings/quotes/edit. "Invalid option selected. Recalculate shipping quotes to continue" simply means there were no available shipping methods for the order, given your conditions and the order details. It's almost certainly a configuration issue.
Comment #4
sah62 CreditAttribution: sah62 commentedThanks for the quick response, TR. Here's the debug info.
I'm getting a quote just fine. When I try to proceed with checkout or hit the "Review Order" button I get the "Invalid option selected. Recalculate shipping quotes to continue." error.
Comment #5
sah62 CreditAttribution: sah62 commentedMore debug info:
The uc_usps_quote function is returning an empty array because the value of $destination->zone is zero:
Selecting Belgium as the delivery country doesn't allow the user to enter a value for "State/Province". I just looked in my database and sure enough there are no zones identified for country 56, but I have what I think is the most recent CIF file (belgium_56_3.cif) in uc_store/countries. I run update.php with every module update.
I just added the needed rows manually to the uc_zones table, but is there a better way to do this automatically in the future if it happens again? There is no update link available for Belgium in my admin interface (admin/store/settings/countries/edit) and the version identified is indeed 3.
Comment #6
TR CreditAttribution: TR commentedThanks for tracking that down. Changed title to reflect the problem. As a workaround you should be able to remove that check on
empty($destination->zone)
- it won't break anything. The reason the check is there is described in the code comments - it just reduces calls to the USPS web server by first checking to see if all needed information has been provided.Comment #7
sah62 CreditAttribution: sah62 commentedThanks, TR. That explains why I could get a quote without error. The zones are specified in belgium_56_3.cif, but for some reason they don't appear to have ever been added to my database.
Comment #8
Timon Davis CreditAttribution: Timon Davis commentedThis patch verifies that the country listed in the address is tied to any zones. If the country is not tied to any zones, then no zones will be required as part of the shipping address. If the country in the address has zones, the zone must still be specified, or be rejected by the system.
Comment #9
peachykeen CreditAttribution: peachykeen commentedPatch in #8 fixed this error for me on 6.x-2.7.
Comment #10
longwaveComment #12
peachykeen CreditAttribution: peachykeen commentedUpdated Timon's patch for the correct directory structure.
Comment #13
TR CreditAttribution: TR commentedZones aren't even used for USPS international shipping quotes, so the patch can skip the DB query - all it needs to do is check the country first then if it's US check the other fields.
Comment #14
peachykeen CreditAttribution: peachykeen commentedThis patch skips the query.
Comment #15
TR CreditAttribution: TR commentedThat won't work - if zone is empty your code doesn't even check the country ... You want to check the country first, and only if the country is US should you check the other fields.
Comment #16
j0rd CreditAttribution: j0rd commentedI've got this problem as well. I've taken TR's last comments and formatted a patch. I hope this is proper logic.
It seems to at least get me to the payment review checkout page.
Comment #17
j0rd CreditAttribution: j0rd commentedNeeds review to test patch? ;)
Comment #18
j0rd CreditAttribution: j0rd commentedBeen running this patch for a week and it resolves my issue. No complaints from clients anymore. Would be nice to get some others to test it, so it can get committed.
Comment #19
longwaveSlightly modified version of the above that improves comments, fixes whitespace, and is slightly more readable (I think). Untested, but happy with the logic and can commit to both branches if someone can confirm this works.
Comment #20
the_g_bomb CreditAttribution: the_g_bomb commentedI just installed the patch, installs cleanly. However after applying the patch I can no longer get shipping quotes using the USPS service. Can't test any further as shipping quote selection is required.
Comment #21
longwaveTry #16 instead.
Comment #22
the_g_bomb CreditAttribution: the_g_bomb commentedTested a little further it could be to do with the removal of the $destination = (object) $details; line.
- $destination = (object) $details;
Comment #23
longwaveYeah I just spotted that, if you add that line back does it work?
Comment #24
the_g_bomb CreditAttribution: the_g_bomb commentedyes, it does
Comment #25
TR CreditAttribution: TR commentedI cannot reproduce this bug with the current 6.x-2.x-dev or 7.x-3.x-dev. I can get USPS quotes without problem for destination countries with or without defined zones.
Comment #26
the_g_bomb CreditAttribution: the_g_bomb commentedI think the problem occurs when you try to submit that order with a country like Singapore or Isle of Man selected where the region doesn't exsist.
Comment #27
TR CreditAttribution: TR commentedI specifically tested both Isle of Man and Singapore before I posted #25, plus a half dozen other countries with no zones. As I said, I cannot reproduce this failure with the current -dev releases. I'm inclined to mark this "closed (cannot reproduce)" unless someone chimes in to demonstrate that this is still a problem in the current -dev.
Comment #28
longwave@TR: so what is $destination->zone set to in these cases? It seems like it should be empty (0) if there are no zones for the country, which would fail the test.
Comment #29
TR CreditAttribution: TR commentedIn D6, $destination->zone contains the string "-1" for countries without zones, and contains an empty string "" for countries with zones but with no zone selected. In D6 there is still a zone select box even when a country doesn't have zones, but it only has one choice, "Not applicable", with a key of "-1".
In D7, $destination->zone also contains the integer 0 for countries with zones but with no zone selected.
But when you select a country without zones, the value of $destination->zone does not get reset - it retains the value from the previous selection. This is a problem, and yes in D7 this will lead to a failed quote, or not, depending on the sequence of selection activity in the delivery address pane. My tests were to populate the delivery address with a saved address, then change country to a country with no zones. That sequence ensured $destination->zone always had a value.
I'll rework the patch and put it in after I test it.
Comment #30
TR CreditAttribution: TR commentedCommitted a fix to both branches after extensive testing with all the available countries.