I was having an issue where the shipping error message (uc_quote_err_msg, "There were problems getting a shipping quote...") was not always showing when there were no suitable shipping quotes returned. Instead, the shipping quote box would be left blank until the "click to calculate shipping" button was clicked two or more times.

I traced it to line 599 of uc_quote.module:
$order->quote_form = uc_quote_build_quote_form($order, !empty($form_state['quote_requested']));

Removing the second parameter forced the parameter to default to TRUE and showed the error every time.

I'm not sure if I've set up my custom shipping modules correctly - basically there are places where they don't want to ship, so I'm not always returning a quote - so this might end up going down as "working as intended".

Comments

longwave’s picture

This should be "works as designed", the reason the parameter is there is to avoid showing an error message until the user explicitly requests a quote by pressing the button - for example if you have rules that depend on zip code, and the zip code is blank when the user first gets to checkout, ideally we want to avoid immediately showing them an error message.

However, you say you have to click the button "two or more times" - you should only have to click it once for the error to show up if there are no valid quotes available.

johnmcc’s picture

Hi there, thanks for the response.

To confirm, I understand that there are situations where the quote will not display on page load. That isn't the issue - the problem is that it is taking two or more clicks on the calculate shipping button to see the error message. On the first click, I'm seeing an empty box, as if I had arrived at the page and no quote was being displayed.

Removing the check of $form_state['quote_requested'] is allowing the error to display the first time the button is clicked.

longwave’s picture

Yes, it seems that this is a valid bug, but the original code must have been there for a reason, so before simply removing it I would like to understand why it is there at all.

longwave’s picture

longwave’s picture

Status: Active » Postponed (maintainer needs more info)

Actually I don't think this is the same as #1453306: Selecting an address from the drop down at checkout doesn't trigger shipping costs or triggers incorrect shipping costs, as that is only triggered when using the "previous addresses" dropdown. I can't reproduce this with the flat rate shipping method provided with core - are you able to do this? Do you have any Rules conditions applied to the shipping methods?

longwave’s picture

Status: Postponed (maintainer needs more info) » Closed (cannot reproduce)

No further info provided.

longwave’s picture

Issue summary: View changes

Formatted code properly

stewart.adam’s picture

Version: 7.x-3.4 » 7.x-3.6
Issue summary: View changes
Status: Closed (cannot reproduce) » Active

I have the same issue and can reproduce on the latest version of Ubercart. Simply set up a flat rate shipping method and set a bogus condition on it (e.g. site:name == asd) and then enable only this shipping method. Users must fill in their address and then click the quote button twice before getting an error message.

I agree that the first request shouldn't have an error set, but here there are two requests with no error message - this is because uc_checkout_pane_quotes() is called before uc_quote_checkout_pane_quotes_submit(), so $form_state['quote_requested'] does get flagged on the first time clicking the button, it gets flagged after the form has already been generated so it takes another request to display the error message.

Quick workaround: set $form_state['quote_requested'] = TRUE; after rendering the form the first time in uc_checkout_pane_quotes(), i.e. just after the line $order->quote_form = uc_quote_build_quote_form($order, !empty($form_state['quote_requested']));.