Uncaught TypeError
-
Hi,
I’m running PixelYourSite Free 11.2.0.7 on a WooCommerce store (duck.rs), and I’m seeing a consistent JavaScript error when customers click “Add to Cart” on the single product page for variable products (color/size selection).
Error:
Uncaught TypeError: Cannot read properties of undefined (reading ‘find’)
at Object.onWooAddToCartOnSingleEvent (public.js?ver=11.2.0.7:3056:49)
at HTMLButtonElement. (public.js?ver=11.2.0.7:3529:25)This happens on every add-to-cart attempt for variable products and appears to block/interfere with the add-to-cart action, based on session recordings showing repeated rage-clicks on the button at the moment of the error.
Looking at the public.js source, I believe the root cause is a mismatch in function signatures for onWooAddToCartOnSingleEvent between different pixel modules:
- Pinterest/Bing dummy implementations use 5 parameters:
function (product_id, qty, is_variable, is_external, $form) - Facebook/GA implementations use 4 parameters:
function (product_id, qty, product_type, $form)
If the click handler (around line 3529) invokes this function using the 5-argument order, then for the Facebook/GA implementations, the $form parameter actually receives the 5th argument (e.g. is_external) instead of the real jQuery form object. This makes $form undefined, so the call to $form.find(‘input[name=”variation_id”]’) throws the TypeError above.
Happy to provide any additional information if useful for debugging.
Thanks!
The page I need help with: [log in to see the link]
- Pinterest/Bing dummy implementations use 5 parameters:
You must be logged in to reply to this topic.