Dear Uberteam,

Here is a patch to eliminate the excessive ajax calls to /taxes/calculate on the checkout form.

Basically I've adjusted the JS file so that the tax calculation call is predicated on the following:

  • We have a valid serialized order object (this condition was already in the JS code)
  • The tax conditions (billing or shipping postal code) have changed since the last ajax call or this is the first time doing the request
  • There's not another pending ajax request to the tax calculator

This should boost the performance of the checkout page pretty dramatically.

Noah Lively
www.koremedia.net

Comments

tr’s picture

Status: Patch (to be ported) » Needs review

I think this is a good idea. Should probably also be done for shipping and payments ...

Island Usurper’s picture

Status: Needs review » Needs work

I really like the check to make sure that the billing and delivery addresses have actually changed. It should probably also check the zone and country as well as the postal code, especially if we also use this for shipping quotes.

Unfortunately, I don't think we should check to make sure another request is still pending. In some cases, we actually want to display the later request because it was triggered by an address change. If we prevent that one from happening, we'll get inaccurate totals displayed in the payment pane. The line items display already makes sure that it's the last request that gets displayed, so I don't think we need to worry about that here.

Please indent with 2 spaces when submitting patches, per the Drupal coding standards.

damienmckenna’s picture

Am having serious problems with this on a site - with Firefox (3.6) and Safari (5.0.1) it works fine but just stacks up thousands upon thousands of XHR requests, IE 8 on the other hand is completely unable to complete the order.

damienmckenna’s picture

Category: task » bug
Issue tags: +checkout

Am changing this to a bug report as the page just should not be doing this. Also, tagging it with the 'checkout' tag.

tr’s picture

@DamienMcKenna: When you say "Am having serious problems with this ..." are you referring to the patch?

damienmckenna’s picture

The key issue is that the AJAX request should only happen when the form has been modified, rather than running on a constant loop.

damienmckenna’s picture

@TR: sorry for being vague: the heavy AJAX calls appear to be causing major problems for IE users (#684552: Payment summary never loads in IE (Checkout) -- but in FF), I haven't tried the patch yet, am about to.

tr’s picture

@DamienMcKenna: It doesn't run in a loop. If your site is looping, it indicates a problem on your site. You didn't answer my question in #5. If your issue is not with the patch you should open a new issue. The patch reduces Ajax calls, but there are *never* thousands of calls on that page.

damienmckenna’s picture

Please also review #646660: Javascript issue with getTax() in uc_taxes, which is related.

tr’s picture

Category: bug » task

Setting back to task. Comments #3 through #9 are unrelated and are being handled in #646660: Javascript issue with getTax() in uc_taxes.

The current status of the original patch is that it needs to be re-rolled taking into account Island Usurper's comments from #2.

damienmckenna’s picture

Status: Needs work » Needs review
StatusFileSize
new1.97 KB

Here's a version of the patch that follows the coding standards better but doesn't stop it if there's a pending request, as suggested in comment #2. I didn't add any logic to see if any of the address changed because that wouldn't work for pickup orders where an address is not required.

smptebars1’s picture

Thanks Noah, I will try this patch tomorrow.

Status: Needs review » Needs work

The last submitted patch, ubercart-n629964-11.patch, failed testing.

smptebars1’s picture

use Noah's patch at the top of this page uc-taxes-patche.txt

longwave’s picture

Status: Needs work » Closed (won't fix)

Not worth changing this now in 6.x, unfortunately.