Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"Invalid Zip Entered" Error when Automated Taxes are enabled. #1576

Closed
zwiesman31 opened this issue Feb 11, 2019 · 11 comments · Fixed by #2310
Closed

"Invalid Zip Entered" Error when Automated Taxes are enabled. #1576

zwiesman31 opened this issue Feb 11, 2019 · 11 comments · Fixed by #2310

Comments

@zwiesman31
Copy link

zwiesman31 commented Feb 11, 2019

Howdy!

When "Automated Taxes" are enabled:

http://cld.wthms.co/Na5KQS
Image link: http://cld.wthms.co/Na5KQS

And a user enters an invalid zipcode at checkout, then navigates back to the cart page, it is impossible for them to get back to the checkout page, as this error is displayed instead:

http://cld.wthms.co/mfIghX
Image link: http://cld.wthms.co/mfIghX

Now, in the settings under WooCommerce > Settings > Shipping > Shipping Options we could select the Enable shipping calculator on the cart page option, then change the zip that way, but not all users want that option enabled:

http://cld.wthms.co/9XWlt8
Image link: http://cld.wthms.co/9XWlt8

Here's a full screencast showing the error:

http://cld.wthms.co/m4dspm
Screencast link: http://cld.wthms.co/m4dspm

@dechov
Copy link
Contributor

dechov commented Feb 19, 2019

Looked into this a bit – the error (initially added in #1489) shouldn't be shown on the Cart when the shipping calculator isn't enabled. Tried to prevent it by bailing out if is_cart() && 'no' === get_option( 'woocommerce_enable_shipping_calc' ) but it doesn't seem to be so simple.

@SiR-DanieL
Copy link
Member

one more report in 4668624-hc

@TMcLoone
Copy link

I've just encountered this issue. Happens if a user takes a little longer to enter in the zipcode and they get booted out. They have to clear cache to get back in. Any ideas how to fix?

@zargogo
Copy link

zargogo commented Jul 11, 2020

I am encountering this issue when a customer adds a product, goes to checkout, inputs a false ZIP and then closes checkout. When it is re-opened it just throws the error message. Disabling Jetpack resolves the problem

@frosso
Copy link
Contributor

frosso commented Nov 4, 2020

From a preliminary investigation, it looks like the issue is caused by the notices displayed on the checkout page when the "debug" checkout flag is "on" and both the "USPS live rates" and the "automatic taxes" functionality of the plugin are enabled.

Screen Shot 2020-11-04 at 9 37 44 AM

If a site has the "debug" functionality enabled and only the automatic taxes functionality enabled, the issue does not present itself. In my testing the issue presents itself only when the "debug" checkout flag is "on" and both the "USPS live rates" and the "automatic taxes" functionality of the plugin are enabled.

By disabling the "debug" option in WooCommerce > Status > Debug, I am again able to interact with the fields in the checkout page. I think it can be assumed that a "live" site in production would not keep the "debug" flag enabled.

A possible solution would be to enable the automatic tax calculation at checkout only on AJAX requests: #2246
An alternative could be to display the debug messages only on AJAX requests.

@frosso
Copy link
Contributor

frosso commented Nov 10, 2020

Discussed on team meeting Nov 10th.
A few different implementation ideas came up.
We'll change the implementation so that if TaxJar tells us about any error with the billing, we'll clear out the ZIP code at minimum (or the whole billing) so that it's not cached.

This will allow customers to edit their cart again.

@JBSurfs
Copy link

JBSurfs commented Dec 9, 2020

Having the same problem for months now. Tried the suggestions from 2246, but I am not getting the same results. I have taxes on, turned debug off and still get the same error message on checkout for wrong zip or taking too long to enter zip. Additionally, I am unsure of the usps live rates being on or off. I can not find how to turn it off without additional problems. ( i offer free shipping, so I don't need any calculations on shipping, but do like to print USPS through woocommerce) Will turn jetpack back off unless there is another easy work around.

@Ferdev
Copy link
Contributor

Ferdev commented Jan 15, 2021

I've been investigating this issue and I'd like to shed more light on the root of the problem.

The problem comes because, as part of the taxes calculation process, whenever there's a problem with the zip code we add an error notice. Adding error notices during checkout load time, makes WooCommerce to display an special template that shows cart errors, and stops loading the rest of the checkout page. error notices can be added, though, during the checkout process that is triggered when the process checkout button is pressed.

The code that calculates taxes in WooCommerce Shipping is attached to the woocommerce_calculate_totals action, which triggers every time the checkout page is loaded.

Also, just removing the invalid zip code won't fix this issue, as the error notice will still be displayed and this will cause the same error. We would also need to display this notice only for AJAX calls.

But the proper way to fix this would be to split the tax calculation process in two parts:

  1. Calculate taxes only when the process checkout button is pressed, and cache the results.
  2. Display the cached results during the woocommerce_calculate_totals action.

This should completely fix the problem while following WooCommerce standards.

@c-shultz
Copy link
Contributor

@Ferdev, I'm trying to remember the different ideas we discussed. Could another fix for this be for WooCommerce Core to display errors differently, so a notice is shown instead of a whole new template/screen?

@Ferdev
Copy link
Contributor

Ferdev commented Jan 18, 2021

I think WooCommerce Core added that functionality on purpose, because they don't want to show errors on page load, but I'm gonna check that with Proton and will come back with an update 👍

@Ferdev
Copy link
Contributor

Ferdev commented Jan 18, 2021

Just checked and yeah, that functionality has been in WooCommerce Core for at least 8 years:

https://github.com/woocommerce/woocommerce/blob/bfcb3ec1e9569d32b9653f83485632a6d4040086/shortcodes/shortcode-checkout.php#L54-L57

They show that page if there's an error notice and the page has no $POST data. I think it makes sense, and it's actually a problem in the implementation of the TaxJar php class.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment