The cart shipping estimate pane in the 6.x-2.x branch is broken due to the form callback not having the proper argument list for 6.x. Symptoms are that the quote callback has a product definition defined in the page's scripts that looks something like the following, which results in empty quotes or errors (this cart had three line items in it):


<!--//--><![CDATA[//><!--
$(function() {
    setQuoteCallbacks("%5E%5E%5E%5E%5E%5E%5E%5EN%3B%7C%5E%5E%5E%5E%5E%5E%5E%5EN%3B%7C%5E%5E%5E%5E%5E%5E%5E%5EN%3B");
    $("#uc-cart-pane-quotes").submit(function() {
      quoteCallback("%5E%5E%5E%5E%5E%5E%5E%5EN%3B%7C%5E%5E%5E%5E%5E%5E%5E%5EN%3B%7C%5E%5E%5E%5E%5E%5E%5E%5EN%3B");
      return false;
    });
  })
//--><!]]>

The regular checkout page's quote pane appears to be working properly (a different form callback is involved).

Patch attached.

CommentFileSizeAuthor
uc_quote.module-uc_cart_pane_quotes.patch578 bytesarpieb
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

arpieb’s picture

Title: Cart checkout pane - no packages, failed quote - PATCH » View cart shipping pane - no packages, failed quote - PATCH
TR’s picture

Title: View cart shipping pane - no packages, failed quote - PATCH » View cart shipping pane - no packages, failed quote
Status: Active » Needs review
wasare’s picture

Status: Needs review » Reviewed & tested by the community

This patch fixed my trouble with the estimated shipping cost at cart pane.

Big thanks arpieb!

TR’s picture

Status: Reviewed & tested by the community » Postponed (maintainer needs more info)

OK, so here's what I don't understand. That function has had the same signature for many years, yet shipping quotes on the /cart page have worked (for me at least) that whole time. I just verified it again - I have no problems getting shipping quotes on the /cart page. I'm pretty sure that if this was fundamentally broken there would have been hundreds of bug reports over 2+ years since Ubercart was ported to Drupal 6.

So I'm not confident that you've identified the problem and the solution. You don't say what shipping methods you're using, but some methods require country, state/province, and postal code in order to give a quote, some only require postal code, some require country and postal code, etc. If a quote request gets submitted without all the proper information, the quote will fail.

I'm also confused about your comment about the JavaScript because shipping quotes on the /cart page don't use JavaScript.

longwave’s picture

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

Patch looks good to me, actually. uc_cart_pane_quotes() is called using drupal_get_form('uc_cart_pane_quotes', $items) so the first argument should be $form_state in D6.

The remaining code then appears to fail in the following two subtle ways:

  • $method['quote']['type'] == $shipping_type tests the wrong thing, but this does not matter for most (all?) shipping methods as they use type 'order' instead.
  • The JavaScript quoteCallback() function is supplied with invalid product data for the Ajax callback, but then somehow this still works sometimes?

The last bit I don't quite understand without further testing, so putting back to "needs review" for now.

arpieb’s picture

@TR, if you're using any quoting method that requires the weight and package count (i.e. UPS, and USPS International non-flat-rate to name two bundled with UC 2.x) the existing code's not even populating the array it passes to the hooks with weight or package information (since it's not pulling the data from the correct argument). As a result, the quoting module(s) wind up with an empty result set being built for the quote. UPS' servers return an error for "no packages" and USPS just fails - presumably because there is no weight.

Some quote modules might have a default fall-back quoting mechanism that doesn't require weight or package count, but at least two of them bundled with UC 2.x (above) need that info.

Regarding the Javascript - it's in there. There are AJAX calls being made to retrieve the quotes without refreshing the entire page, and I've traced the calls to find that little snippet of malformed content posted above is what is being passed to the callbacks in UC's D6 code. Not really many other ways to do that unless you're using ActiveX or Java, and AFAICT that's not the case.

longwave’s picture

Status: Needs review » Fixed

Committed.

Status: Fixed » Closed (fixed)

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