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?

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

sah62’s picture

Hmm, 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?

sah62’s picture

...and now it's acting up again. This is strange!

TR’s picture

Category: bug » support
Status: Active » Postponed (maintainer needs more info)

Please 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.

sah62’s picture

Thanks for the quick response, TR. Here's the debug info.

API=IntlRateV2&XML=<IntlRateV2Request USERID="MyID"><Revision>2</Revision><Package ID="0"><Pounds>0</Pounds><Ounces>2</Ounces><MailType>All</MailType><ValueOfContents>10</ValueOfContents><Country>Belgium</Country><Container>RECTANGULAR</Container><Size>REGULAR</Size><Width></Width><Length></Length><Height></Height><Girth></Girth><OriginZip>22009</OriginZip></Package></IntlRateV2Request>

<?xml version="1.0"?>
<IntlRateV2Response><Package ID="0"><Prohibitions>Arms and weapons.
Bronze, copper, and nickel coins not legal tender in Belgium, unless imported for collections.
Human remains.
Live plants and animals.
Perishable infectious biological substances.
Radioactive materials.</Prohibitions><Restrictions>No list furnished.</Restrictions><Observations>1. Priority Mail International parcels must have a street address. Delivery cannot be made to post office boxes. A local telephone number for the addressee should be provided. 
2. For Priority Mail International parcels, an invoice, in duplicate, is required for all commercial shipments regardless of value and all personal shipments valued at $300 or more. The invoices must be affixed to the outside of the parcel or may be enclosed in PS Form 2976-E with the customs declaration. 
3. Import permits or licenses are required for many types of goods; therefore, the sender should ascertain from the addressee before mailing whether the necessary documents are held. 
4. Gift shipments for private individuals for their personal use are exempt from the license requirement provided the value of the shipment does not exceed 74 euros.</Observations><CustomsForms>First-Class Mail International items and Priority Mail International Flat Rate Envelopes and Small Flat Rate Boxes: 
PS Form 2976 (see 123.61)
Priority Mail International parcels:
PS Form 2976-A inside 2976-E (envelope)</CustomsForms><ExpressMail>Country Code: BE

Reciprocal Service Name: Datapost

Required Customs Form/Endorsement:
1. Business correspondence, commercial papers and documents, and clearances between financial institutions. 
PS Form 2976, Customs - CN 22 and Sender's Declaration. Endorse item clearly next to mailing label as BUSINESS PAPERS. 

2. Merchandise samples without commercial value, computer data including computer cards, magnetic tape, microfilm, and microfiche.
PS Form 2976-A, Customs Declaration and Dispatch Note CP 72, inside a PS Form 2976-E, Customs Declaration Envelope CP 91. 

3. Merchandise and all articles subject to customs duty. 
PS Form 2976-A, Customs Declaration and Dispatch Note CP 72, inside a PS Form 2976-E, Customs Declaration Envelope CP 91. An invoice, in duplicate, is required for all commercial shipments regardless of value and all personal shipments valued at $300 or more. The invoices must be either affixed to the outside of the parcel or enclosed in PS Form 2976-E with the customs declaration.  

Notes:
1. An invoice, in duplicate, is required for all commercial shipments regardless of value and for all personal shipments valued at $300 or more. The invoices must be either affixed to the outside of the parcel or enclosed in PS Form 2976-E with the customs declaration. 
2. Arms, weapons, and human remains are prohibited. 
3. Coins; banknotes; currency notes, including paper money; securities of any kind payable to bearer; traveler's checks; platinum, gold, and silver; precious stones; jewelry; watches; and other valuable articles are prohibited in Express Mail International shipments to Belgium. 
4. Express Mail International shipments must have a street address. Post office box addresses cannot be used. A local telephone number for addressee should be provided if possible.

Areas Served: All</ExpressMail><AreasServed>Please reference Express Mail for Areas Served.</AreasServed><AdditionalRestrictions>No Additional Restrictions Data found.</AdditionalRestrictions><Service ID="12"><Pounds>0</Pounds><Ounces>2</Ounces><MailType>All</MailType><Container>RECTANGULAR</Container><Size>REGULAR</Size><Width>0</Width><Length>0</Length><Height>0</Height><Girth>0</Girth><Country>BELGIUM</Country><Postage>44.75</Postage><ExtraServices><ExtraService><ServiceID>1</ServiceID><ServiceName>Insurance</ServiceName><Available>True</Available><Price>1.00</Price></ExtraService><ExtraService><ServiceID>5</ServiceID><ServiceName>Pick-up</ServiceName><Available>True</Available><Price>15.30</Price></ExtraService></ExtraServices><ValueOfContents>10.00</ValueOfContents><SvcCommitments>1 - 3 business days</SvcCommitments><SvcDescription>USPS GXG&amp;lt;sup&amp;gt;&amp;amp;trade;&amp;lt;/sup&amp;gt; Envelopes**</SvcDescription><MaxDimensions>Cardboard envelope has a dimension of 12-1/2" x 9-1/2" and GXG tyvek envelope has a dimension of 15-1/2" x 12-1/2"</MaxDimensions><MaxWeight>70</MaxWeight></Service><Service ID="1"><Pounds>0</Pounds><Ounces>2</Ounces><MailType>All</MailType><Container>RECTANGULAR</Container><Size>REGULAR</Size><Width>0</Width><Length>0</Length><Height>0</Height><Girth>0</Girth><Country>BELGIUM</Country><Postage>29.95</Postage><ExtraServices><ExtraService><ServiceID>1</ServiceID><ServiceName>Insurance</ServiceName><Available>True</Available><Price>0.80</Price></ExtraService><ExtraService><ServiceID>5</ServiceID><ServiceName>Pick-up</ServiceName><Available>True</Available><Price>15.30</Price></ExtraService></ExtraServices><ValueOfContents>10.00</ValueOfContents><SvcCommitments>3 - 5 business days</SvcCommitments><SvcDescription>Express Mail&amp;lt;sup&amp;gt;&amp;amp;reg;&amp;lt;/sup&amp;gt; International</SvcDescription><MaxDimensions>Max. length 60", max. length plus girth combined 108"</MaxDimensions><MaxWeight>66</MaxWeight></Service><Service ID="10"><Pounds>0</Pounds><Ounces>2</Ounces><MailType>All</MailType><Container>RECTANGULAR</Container><Size>REGULAR</Size><Width>0</Width><Length>0</Length><Height>0</Height><Girth>0</Girth><Country>BELGIUM</Country><Postage>29.95</Postage><ExtraServices><ExtraService><ServiceID>1</ServiceID><ServiceName>Insurance</ServiceName><Available>True</Available><Price>0.80</Price></ExtraService><ExtraService><ServiceID>5</ServiceID><ServiceName>Pick-up</ServiceName><Available>True</Available><Price>15.30</Price></ExtraService></ExtraServices><ValueOfContents>10.00</ValueOfContents><SvcCommitments>3 - 5 business days</SvcCommitments><SvcDescription>Express Mail&amp;lt;sup&amp;gt;&amp;amp;reg;&amp;lt;/sup&amp;gt; International Flat Rate Envelope</SvcDescription><MaxDimensions>USPS-Produced Envelope: 12-1/2" x 9-1/2"</MaxDimensions><MaxWeight>66</MaxWeight></Service><Service ID="17"><Pounds>0</Pounds><Ounces>2</Ounces><MailType>All</MailType><Container>RECTANGULAR</Container><Size>REGULAR</Size><Width>0</Width><Length>0</Length><Height>0</Height><Girth>0</Girth><Country>BELGIUM</Country><Postage>29.95</Postage><ExtraServices><ExtraService><ServiceID>1</ServiceID><ServiceName>Insurance</ServiceName><Available>True</Available><Price>0.80</Price></ExtraService><ExtraService><ServiceID>5</ServiceID><ServiceName>Pick-up</ServiceName><Available>True</Available><Price>15.30</Price></ExtraService></ExtraServices><ValueOfContents>10.00</ValueOfContents><SvcCommitments>3 - 5 business days</SvcCommitments><SvcDescription>Express Mail&amp;lt;sup&amp;gt;&amp;amp;reg;&amp;lt;/sup&amp;gt; International Legal Flat Rate Envelope</SvcDescription><MaxDimensions>USPS-Produced Envelope: 15" x 9-1/2"</MaxDimensions><MaxWeight>66</MaxWeight></Service><Service ID="2"><Pounds>0</Pounds><Ounces>2</Ounces><MailType>All</MailType><Container>RECTANGULAR</Container><Size>REGULAR</Size><Width>0</Width><Length>0</Length><Height>0</Height><Girth>0</Girth><Country>BELGIUM</Country><Postage>29.25</Postage><ExtraServices><ExtraService><ServiceID>1</ServiceID><ServiceName>Insurance</ServiceName><Available>True</Available><Price>2.30</Price></ExtraService><ExtraService><ServiceID>6</ServiceID><ServiceName>Certificate of Mailing</ServiceName><Available>True</Available><Price>1.15</Price></ExtraService><ExtraService><ServiceID>5</ServiceID><ServiceName>Pick-up</ServiceName><Available>True</Available><Price>15.30</Price></ExtraService></ExtraServices><ValueOfContents>10.00</ValueOfContents><ParcelIndemnityCoverage>10.00</ParcelIndemnityCoverage><SvcCommitments>6 - 10 business days</SvcCommitments><SvcDescription>Priority Mail&amp;lt;sup&amp;gt;&amp;amp;reg;&amp;lt;/sup&amp;gt; International</SvcDescription><MaxDimensions>Max. length 60", max. length plus girth combined 108"</MaxDimensions><MaxWeight>66</MaxWeight></Service><Service ID="11"><Pounds>0</Pounds><Ounces>2</Ounces><MailType>All</MailType><Container>RECTANGULAR</Container><Size>REGULAR</Size><Width>0</Width><Length>0</Length><Height>0</Height><Girth>0</Girth><Country>BELGIUM</Country><Postage>58.50</Postage><ExtraServices><ExtraService><ServiceID>1</ServiceID><ServiceName>Insurance</ServiceName><Available>True</Available><Price>2.30</Price></ExtraService><ExtraService><ServiceID>6</ServiceID><ServiceName>Certificate of Mailing</ServiceName><Available>True</Available><Price>1.15</Price></ExtraService><ExtraService><ServiceID>5</ServiceID><ServiceName>Pick-up</ServiceName><Available>True</Available><Price>15.30</Price></ExtraService></ExtraServices><ValueOfContents>10.00</ValueOfContents><ParcelIndemnityCoverage>10.00</ParcelIndemnityCoverage><SvcCommitments>6 - 10 business days</SvcCommitments><SvcDescription>Priority Mail&amp;lt;sup&amp;gt;&amp;amp;reg;&amp;lt;/sup&amp;gt; International Large Flat Rate Box</SvcDescription><MaxDimensions>USPS-Produced Large Box: 12" x 12" x 5-1/2".&lt;br&gt;Maximum weight 20 pounds.</MaxDimensions><MaxWeight>20</MaxWeight></Service><Service ID="9"><Pounds>0</Pounds><Ounces>2</Ounces><MailType>All</MailType><Container>RECTANGULAR</Container><Size>REGULAR</Size><Width>0</Width><Length>0</Length><Height>0</Height><Girth>0</Girth><Country>BELGIUM</Country><Postage>45.50</Postage><ExtraServices><ExtraService><ServiceID>1</ServiceID><ServiceName>Insurance</ServiceName><Available>True</Available><Price>2.30</Price></ExtraService><ExtraService><ServiceID>6</ServiceID><ServiceName>Certificate of Mailing</ServiceName><Available>True</Available><Price>1.15</Price></ExtraService><ExtraService><ServiceID>5</ServiceID><ServiceName>Pick-up</ServiceName><Available>True</Available><Price>15.30</Price></ExtraService></ExtraServices><ValueOfContents>10.00</ValueOfContents><ParcelIndemnityCoverage>10.00</ParcelIndemnityCoverage><SvcCommitments>6 - 10 business days</SvcCommitments><SvcDescription>Priority Mail&amp;lt;sup&amp;gt;&amp;amp;reg;&amp;lt;/sup&amp;gt; International Medium Flat Rate Box</SvcDescription><MaxDimensions>USPS-Produced Medium Box:&lt;br&gt;13-5/8" x 11-7/8" x 3-3/8" or 11" x 8-1/2" x 5-1/2".&lt;br&gt;Maximum weight 20 pounds.</MaxDimensions><MaxWeight>20</MaxWeight></Service><Service ID="16"><Pounds>0</Pounds><Ounces>2</Ounces><MailType>All</MailType><Container>RECTANGULAR</Container><Size>REGULAR</Size><Width>0</Width><Length>0</Length><Height>0</Height><Girth>0</Girth><Country>BELGIUM</Country><Postage>13.95</Postage><ExtraServices><ExtraService><ServiceID>6</ServiceID><ServiceName>Certificate of Mailing</ServiceName><Available>True</Available><Price>1.15</Price></ExtraService><ExtraService><ServiceID>5</ServiceID><ServiceName>Pick-up</ServiceName><Available>True</Available><Price>15.30</Price></ExtraService><ExtraService><ServiceID>0</ServiceID><ServiceName>Registered Mail</ServiceName><Available>True</Available><Price>11.50</Price></ExtraService></ExtraServices><ValueOfContents>10.00</ValueOfContents><InsComment>SERVICE</InsComment><SvcCommitments>6 - 10 business days</SvcCommitments><SvcDescription>Priority Mail&amp;lt;sup&amp;gt;&amp;amp;reg;&amp;lt;/sup&amp;gt; International Small Flat Rate Box**</SvcDescription><MaxDimensions>USPS-Produced Small Box: 8-5/8" x 5-3/8" x 1-5/8".&lt;br&gt;Maximum weight 4 pounds.</MaxDimensions><MaxWeight>4</MaxWeight></Service><Service ID="24"><Pounds>0</Pounds><Ounces>2</Ounces><MailType>All</MailType><Container>RECTANGULAR</Container><Size>REGULAR</Size><Width>0</Width><Length>0</Length><Height>0</Height><Girth>0</Girth><Country>BELGIUM</Country><Postage>13.95</Postage><ExtraServices><ExtraService><ServiceID>6</ServiceID><ServiceName>Certificate of Mailing</ServiceName><Available>True</Available><Price>1.15</Price></ExtraService><ExtraService><ServiceID>5</ServiceID><ServiceName>Pick-up</ServiceName><Available>True</Available><Price>15.30</Price></ExtraService><ExtraService><ServiceID>0</ServiceID><ServiceName>Registered Mail</ServiceName><Available>True</Available><Price>11.50</Price></ExtraService></ExtraServices><ValueOfContents>10.00</ValueOfContents><InsComment>SERVICE</InsComment><SvcCommitments>6 - 10 business days</SvcCommitments><SvcDescription>Priority Mail&amp;lt;sup&amp;gt;&amp;amp;reg;&amp;lt;/sup&amp;gt; International DVD Flat Rate Box**</SvcDescription><MaxDimensions>USPS-Produced DVD Box: 7-9/16" x 5-7/16" x 1-3/8".&lt;br&gt;Maximum weight 4 pounds.</MaxDimensions><MaxWeight>4</MaxWeight></Service><Service ID="25"><Pounds>0</Pounds><Ounces>2</Ounces><MailType>All</MailType><Container>RECTANGULAR</Container><Size>REGULAR</Size><Width>0</Width><Length>0</Length><Height>0</Height><Girth>0</Girth><Country>BELGIUM</Country><Postage>13.95</Postage><ExtraServices><ExtraService><ServiceID>6</ServiceID><ServiceName>Certificate of Mailing</ServiceName><Available>True</Available><Price>1.15</Price></ExtraService><ExtraService><ServiceID>5</ServiceID><ServiceName>Pick-up</ServiceName><Available>True</Available><Price>15.30</Price></ExtraService><ExtraService><ServiceID>0</ServiceID><ServiceName>Registered Mail</ServiceName><Available>True</Available><Price>11.50</Price></ExtraService></ExtraServices><ValueOfContents>10.00</ValueOfContents><InsComment>SERVICE</InsComment><SvcCommitments>6 - 10 business days</SvcCommitments><SvcDescription>Priority Mail&amp;lt;sup&amp;gt;&amp;amp;reg;&amp;lt;/sup&amp;gt; International Large Video Flat Rate Box**</SvcDescription><MaxDimensions>USPS-Produced Large Video Box: 9-1/4" x 6-1/4" x 2".&lt;br&gt;Maximum weight 4 pounds.</MaxDimensions><MaxWeight>4</MaxWeight></Service><Service ID="8"><Pounds>0</Pounds><Ounces>2</Ounces><MailType>All</MailType><Container>RECTANGULAR</Container><Size>REGULAR</Size><Width>0</Width><Length>0</Length><Height>0</Height><Girth>0</Girth><Country>BELGIUM</Country><Postage>13.95</Postage><ExtraServices><ExtraService><ServiceID>6</ServiceID><ServiceName>Certificate of Mailing</ServiceName><Available>True</Available><Price>1.15</Price></ExtraService><ExtraService><ServiceID>5</ServiceID><ServiceName>Pick-up</ServiceName><Available>True</Available><Price>15.30</Price></ExtraService><ExtraService><ServiceID>0</ServiceID><ServiceName>Registered Mail</ServiceName><Available>True</Available><Price>11.50</Price></ExtraService></ExtraServices><ValueOfContents>10.00</ValueOfContents><InsComment>SERVICE</InsComment><SvcCommitments>6 - 10 business days</SvcCommitments><SvcDescription>Priority Mail&amp;lt;sup&amp;gt;&amp;amp;reg;&amp;lt;/sup&amp;gt; International Flat Rate Envelope**</SvcDescription><MaxDimensions>USPS-Produced Envelope: 12-1/2" x 9-1/2".&lt;br&gt;Maximum weight 4 pounds.</MaxDimensions><MaxWeight>4</MaxWeight></Service><Service ID="22"><Pounds>0</Pounds><Ounces>2</Ounces><MailType>All</MailType><Container>RECTANGULAR</Container><Size>REGULAR</Size><Width>0</Width><Length>0</Length><Height>0</Height><Girth>0</Girth><Country>BELGIUM</Country><Postage>13.95</Postage><ExtraServices><ExtraService><ServiceID>6</ServiceID><ServiceName>Certificate of Mailing</ServiceName><Available>True</Available><Price>1.15</Price></ExtraService><ExtraService><ServiceID>5</ServiceID><ServiceName>Pick-up</ServiceName><Available>True</Available><Price>15.30</Price></ExtraService><ExtraService><ServiceID>0</ServiceID><ServiceName>Registered Mail</ServiceName><Available>True</Available><Price>11.50</Price></ExtraService></ExtraServices><ValueOfContents>10.00</ValueOfContents><InsComment>SERVICE</InsComment><SvcCommitments>6 - 10 business days</SvcCommitments><SvcDescription>Priority Mail&amp;lt;sup&amp;gt;&amp;amp;reg;&amp;lt;/sup&amp;gt; International Legal Flat Rate Envelope**</SvcDescription><MaxDimensions>USPS-Produced Envelope: 15" x 9-1/2".&lt;br&gt;Maximum weight 4 pounds.</MaxDimensions><MaxWeight>4</MaxWeight></Service><Service ID="23"><Pounds>0</Pounds><Ounces>2</Ounces><MailType>All</MailType><Container>RECTANGULAR</Container><Size>REGULAR</Size><Width>0</Width><Length>0</Length><Height>0</Height><Girth>0</Girth><Country>BELGIUM</Country><Postage>13.95</Postage><ExtraServices><ExtraService><ServiceID>6</ServiceID><ServiceName>Certificate of Mailing</ServiceName><Available>True</Available><Price>1.15</Price></ExtraService><ExtraService><ServiceID>5</ServiceID><ServiceName>Pick-up</ServiceName><Available>True</Available><Price>15.30</Price></ExtraService><ExtraService><ServiceID>0</ServiceID><ServiceName>Registered Mail</ServiceName><Available>True</Available><Price>11.50</Price></ExtraService></ExtraServices><ValueOfContents>10.00</ValueOfContents><InsComment>SERVICE</InsComment><SvcCommitments>6 - 10 business days</SvcCommitments><SvcDescription>Priority Mail&amp;lt;sup&amp;gt;&amp;amp;reg;&amp;lt;/sup&amp;gt; International Padded Flat Rate Envelope**</SvcDescription><MaxDimensions>USPS-Produced Envelope: 12-1/2" x 9-1/2".&lt;br&gt;Maximum weight 4 pounds.</MaxDimensions><MaxWeight>4</MaxWeight></Service><Service ID="18"><Pounds>0</Pounds><Ounces>2</Ounces><MailType>All</MailType><Container>RECTANGULAR</Container><Size>REGULAR</Size><Width>0</Width><Length>0</Length><Height>0</Height><Girth>0</Girth><Country>BELGIUM</Country><Postage>13.95</Postage><ExtraServices><ExtraService><ServiceID>6</ServiceID><ServiceName>Certificate of Mailing</ServiceName><Available>True</Available><Price>1.15</Price></ExtraService><ExtraService><ServiceID>5</ServiceID><ServiceName>Pick-up</ServiceName><Available>True</Available><Price>15.30</Price></ExtraService><ExtraService><ServiceID>0</ServiceID><ServiceName>Registered Mail</ServiceName><Available>True</Available><Price>11.50</Price></ExtraService></ExtraServices><ValueOfContents>10.00</ValueOfContents><InsComment>SERVICE</InsComment><SvcCommitments>6 - 10 business days</SvcCommitments><SvcDescription>Priority Mail&amp;lt;sup&amp;gt;&amp;amp;reg;&amp;lt;/sup&amp;gt; International Gift Card Flat Rate Envelope**</SvcDescription><MaxDimensions>USPS-Produced Envelope: 10" x 7".&lt;br&gt;Maximum weight 4 pounds.</MaxDimensions><MaxWeight>4</MaxWeight></Service><Service ID="20"><Pounds>0</Pounds><Ounces>2</Ounces><MailType>All</MailType><Container>RECTANGULAR</Container><Size>REGULAR</Size><Width>0</Width><Length>0</Length><Height>0</Height><Girth>0</Girth><Country>BELGIUM</Country><Postage>13.95</Postage><ExtraServices><ExtraService><ServiceID>6</ServiceID><ServiceName>Certificate of Mailing</ServiceName><Available>True</Available><Price>1.15</Price></ExtraService><ExtraService><ServiceID>5</ServiceID><ServiceName>Pick-up</ServiceName><Available>True</Available><Price>15.30</Price></ExtraService><ExtraService><ServiceID>0</ServiceID><ServiceName>Registered Mail</ServiceName><Available>True</Available><Price>11.50</Price></ExtraService></ExtraServices><ValueOfContents>10.00</ValueOfContents><InsComment>SERVICE</InsComment><SvcCommitments>6 - 10 business days</SvcCommitments><SvcDescription>Priority Mail&amp;lt;sup&amp;gt;&amp;amp;reg;&amp;lt;/sup&amp;gt; International Small Flat Rate Envelope**</SvcDescription><MaxDimensions>USPS-Produced Envelope: 10" x 6".&lt;br&gt;Maximum weight 4 pounds.</MaxDimensions><MaxWeight>4</MaxWeight></Service><Service ID="19"><Pounds>0</Pounds><Ounces>2</Ounces><MailType>All</MailType><Container>RECTANGULAR</Container><Size>REGULAR</Size><Width>0</Width><Length>0</Length><Height>0</Height><Girth>0</Girth><Country>BELGIUM</Country><Postage>13.95</Postage><ExtraServices><ExtraService><ServiceID>6</ServiceID><ServiceName>Certificate of Mailing</ServiceName><Available>True</Available><Price>1.15</Price></ExtraService><ExtraService><ServiceID>5</ServiceID><ServiceName>Pick-up</ServiceName><Available>True</Available><Price>15.30</Price></ExtraService><ExtraService><ServiceID>0</ServiceID><ServiceName>Registered Mail</ServiceName><Available>True</Available><Price>11.50</Price></ExtraService></ExtraServices><ValueOfContents>10.00</ValueOfContents><InsComment>SERVICE</InsComment><SvcCommitments>6 - 10 business days</SvcCommitments><SvcDescription>Priority Mail&amp;lt;sup&amp;gt;&amp;amp;reg;&amp;lt;/sup&amp;gt; International Window Flat Rate Envelope**</SvcDescription><MaxDimensions>USPS-Produced Envelope: 10" x 5".&lt;br&gt;Maximum weight 4 pounds.</MaxDimensions><MaxWeight>4</MaxWeight></Service><Service ID="15"><Pounds>0</Pounds><Ounces>2</Ounces><MailType>All</MailType><Container>RECTANGULAR</Container><Size>REGULAR</Size><Width>0</Width><Length>0</Length><Height>0</Height><Girth>0</Girth><Country>BELGIUM</Country><Postage>2.59</Postage><ExtraServices><ExtraService><ServiceID>6</ServiceID><ServiceName>Certificate of Mailing</ServiceName><Available>True</Available><Price>1.15</Price></ExtraService><ExtraService><ServiceID>0</ServiceID><ServiceName>Registered Mail</ServiceName><Available>True</Available><Price>11.50</Price></ExtraService></ExtraServices><ValueOfContents>10.00</ValueOfContents><InsComment>SERVICE</InsComment><SvcCommitments>Varies by country</SvcCommitments><SvcDescription>First-Class Mail&amp;lt;sup&amp;gt;&amp;amp;reg;&amp;lt;/sup&amp;gt; International Package**</SvcDescription><MaxDimensions>Other than rolls: Max. length 24", max length, height and depth (thickness) combined 36"&lt;br&gt;Rolls: Max. length 36". Max length and twice the diameter combined 42"</MaxDimensions><MaxWeight>4</MaxWeight></Service><Service ID="14"><Pounds>0</Pounds><Ounces>2</Ounces><MailType>All</MailType><Container>RECTANGULAR</Container><Size>REGULAR</Size><Width>0</Width><Length>0</Length><Height>0</Height><Girth>0</Girth><Country>BELGIUM</Country><Postage>2.17</Postage><ExtraServices><ExtraService><ServiceID>6</ServiceID><ServiceName>Certificate of Mailing</ServiceName><Available>True</Available><Price>1.15</Price></ExtraService><ExtraService><ServiceID>0</ServiceID><ServiceName>Registered Mail</ServiceName><Available>True</Available><Price>11.50</Price></ExtraService></ExtraServices><ValueOfContents>10.00</ValueOfContents><InsComment>SERVICE</InsComment><SvcCommitments>Varies by country</SvcCommitments><SvcDescription>First-Class Mail&amp;lt;sup&amp;gt;&amp;amp;reg;&amp;lt;/sup&amp;gt; International Large Envelope**</SvcDescription><MaxDimensions>Max. length 15", height 12" or thickness 3/4"</MaxDimensions><MaxWeight>4</MaxWeight></Service><Service ID="13"><Pounds>0</Pounds><Ounces>2</Ounces><MailType>All</MailType><Container>RECTANGULAR</Container><Size>REGULAR</Size><Width>0</Width><Length>0</Length><Height>0</Height><Girth>0</Girth><Country>BELGIUM</Country><Postage>1.82</Postage><ExtraServices><ExtraService><ServiceID>6</ServiceID><ServiceName>Certificate of Mailing</ServiceName><Available>True</Available><Price>1.15</Price></ExtraService><ExtraService><ServiceID>0</ServiceID><ServiceName>Registered Mail</ServiceName><Available>True</Available><Price>11.50</Price></ExtraService></ExtraServices><ValueOfContents>10.00</ValueOfContents><InsComment>SERVICE</InsComment><SvcCommitments>Varies by country</SvcCommitments><SvcDescription>First-Class Mail&amp;lt;sup&amp;gt;&amp;amp;reg;&amp;lt;/sup&amp;gt; International Letter**</SvcDescription><MaxDimensions>Max. length 11-1/2", height 6-1/8" or thickness 1/4"</MaxDimensions><MaxWeight>0.21875</MaxWeight></Service></Package></IntlRateV2Response>

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.

sah62’s picture

More debug info:

The uc_usps_quote function is returning an empty array because the value of $destination->zone is zero:

  if (empty($destination->zone)        ||
      empty($destination->postal_code) ||
      empty($destination->country)       ) {
    // Skip this shipping method.
drupal_set_message('Destination:<pre>'. print_r($destination, TRUE) .'</pre>');
    return array();
  }

Destination:
stdClass Object
(
    [first_name] => First
    [last_name] => Last
    [company] => 
    [street1] => Gasthuisstraat 27
    [street2] => 
    [city] => Temse
    [zone] => 0
    [postal_code] => 9140
    [country] => 56
    [phone] => 037711817
)

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.

TR’s picture

Title: Another "Invalid option selected. Recalculate shipping quotes to continue." » USPS Intl quotes don't work when the destination country doesn't have zones
Category: support » bug
Status: Postponed (maintainer needs more info) » Active

Thanks 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.

sah62’s picture

Thanks, 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.

Timon Davis’s picture

This 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.

peachykeen’s picture

Patch in #8 fixed this error for me on 6.x-2.7.

longwave’s picture

Status: Active » Needs review

Status: Needs review » Needs work

The last submitted patch, uc_usps-address_zone_validation-1139338-8.patch, failed testing.

peachykeen’s picture

Status: Needs work » Needs review
FileSize
1.05 KB

Updated Timon's patch for the correct directory structure.

TR’s picture

Status: Needs review » Needs work

Zones 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.

peachykeen’s picture

Status: Needs work » Needs review
FileSize
814 bytes

This patch skips the query.

TR’s picture

Status: Needs review » Needs work

That 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.

j0rd’s picture

I'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.

j0rd’s picture

Status: Needs work » Needs review

Needs review to test patch? ;)

j0rd’s picture

Been 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.

longwave’s picture

FileSize
941 bytes

Slightly 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.

the_g_bomb’s picture

I 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.

longwave’s picture

Try #16 instead.

the_g_bomb’s picture

Tested a little further it could be to do with the removal of the $destination = (object) $details; line.
- $destination = (object) $details;

longwave’s picture

Yeah I just spotted that, if you add that line back does it work?

the_g_bomb’s picture

yes, it does

TR’s picture

Status: Needs review » Postponed (maintainer needs more info)

I 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.

the_g_bomb’s picture

I 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.

TR’s picture

I 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.

longwave’s picture

@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.

TR’s picture

Version: 6.x-2.x-dev » 7.x-3.x-dev
Assigned: Unassigned » TR
Status: Postponed (maintainer needs more info) » Active

In 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.

TR’s picture

Status: Active » Fixed

Committed a fix to both branches after extensive testing with all the available countries.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.