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

In out-of-stock single product pages: Uncaught TypeError #558

Closed
htdat opened this issue Apr 18, 2019 · 4 comments · Fixed by #704
Closed

In out-of-stock single product pages: Uncaught TypeError #558

htdat opened this issue Apr 18, 2019 · 4 comments · Fixed by #704
Labels
priority: low The issue/PR is low priority—not many people are affected or there’s a workaround, etc. type: bug The issue is a confirmed bug.

Comments

@htdat
Copy link

htdat commented Apr 18, 2019

This error does not affect the operation but it should be fixed.

Steps to replicate the issue

  1. Create an out-of-stock product.
  2. Visit its single product page.
  3. Check the browser console, this JS error displays:
Uncaught TypeError: Cannot read property 'checkValidity' of undefined
    at validate_form (wc-gateway-ppec-generate-cart.js?ver=1.6.11:46)
    at wc-gateway-ppec-generate-cart.js?ver=1.6.11:70
    at wc-gateway-ppec-generate-cart.js?ver=1.6.11:126

Screen Shot 2019-04-18 at 13 47 29

What expected

No error in the browser console.

Environment

  • Default WP theme.
  • WooCommerce PayPal Checkout Gateway 1.6.11 and WooCommerce 3.6.1

Addtional context

https://wordpress.org/support/topic/uncaught-typeerror-checkvalidity-when-product-is-out-of-stock/

@htdat htdat added the priority: low The issue/PR is low priority—not many people are affected or there’s a workaround, etc. label Apr 18, 2019
@sknzl
Copy link

sknzl commented Jun 26, 2019

Having the same issue here. Since we have a newsletter sign up form in the footer it won't show up on product pages that are out of stock.

@vencreative
Copy link

Same issue is happening with us, however, all products are having this error.

@JakePT
Copy link

JakePT commented Sep 18, 2019

When using a plugin like Autoptimize to concatenate JavaScript, this can cause all scripts to fail. Adding wc-gateway-ppec-generate-cart.js to the exclusions list will resolve that issue, but the error still appears in the console.

chickenn00dle added a commit that referenced this issue Mar 27, 2020
Currently, when on a product page containing an item that is out of
stock, both wc-gateway-ppec-smart-payment-buttons.js and
wc-gateway-ppec-generate-cart.js scripts throw exceptions as both
scripts are trying to target elements which don't exist when products
are out of stock.

This PR adds a check for the relevant form element, and returns early if
it is not present.

Fixes #558
@chickenn00dle chickenn00dle added the type: bug The issue is a confirmed bug. label Mar 27, 2020
@chickenn00dle chickenn00dle removed their assignment Mar 30, 2020
@pjrfigueiredo
Copy link

pjrfigueiredo commented Apr 4, 2020

I had a minification plugin (Asset CleanUp: Page Speed Booster) and it was causing this issue.
Disabling it solved my problem.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
priority: low The issue/PR is low priority—not many people are affected or there’s a workaround, etc. type: bug The issue is a confirmed bug.
Projects
None yet
7 participants