• Resolved dmncvs

    (@dmncvs)


    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]

Viewing 6 replies - 1 through 6 (of 6 total)
  • Hi @dmncvs, you’re using an outdated version of the plugin. We recently released a new version, 11.2.1, which fixes the uncaught TypeError you reported. Please update the plugin and check it out; it should work fine.

    • This reply was modified 3 weeks, 6 days ago by ehamati.
    Thread Starter dmncvs

    (@dmncvs)

    Hi,

    Thanks for the quick reply and for the fix in 11.2.1.

    I've updated and confirmed the Facebook/GA signature mismatch is resolved. However, the same error still occurs on variable products — same message, now at public.js?ver=11.2.1:3229:49.

    Looking at the updated source, the fix wasn't applied to the GTM module. The click handler calls:

    GTM.onWooAddToCartOnSingleEvent(product_id, qty, product_type, $form); // 4 arguments

    But the GTM implementation is defined as:

    onWooAddToCartOnSingleEvent: function (product_id, qty, product_type, is_external, $form, prod_info) // 6 parameters

    So the 4th argument (the real $form) is received as is_external, and $form is undefined inside the function. This then throws on:

    if (product_type === Utils.PRODUCT_VARIABLE && !options.gtm.wooVariableAsSimple) {
    product_id = parseInt($form.find('input[name="variation_id"]').val());
    }

    Same root cause as before, just in the GTM module instead of Facebook/GA. Could you check this one too?

    Thanks again for looking into it.
    Thread Starter dmncvs

    (@dmncvs)

    Hi,

    Thanks for maintaining the free version of the plugin — really appreciate it.

    Just a small follow-up: the GTM issue from my previous message still seems to be there in 11.2.1.

    Also, I came across another error while testing, this time on “remove from cart”:

    Uncaught TypeError: Pinterest.tag is not a function
    at Object.fireEventForAllPixel (public.js?ver=11.2.1:564:53)

    Might be worth a quick look at the fallback objects in public.js (dummyPinterest/dummyBing) — one of the other fallback objects has a tag() method defined, so it looks like it might just be missing there.

    Thanks again for all the work on the plugin!

    You’re right about it. I’ve already asked the developers to investigate and fix it shortly.

    Thread Starter dmncvs

    (@dmncvs)

    Hi! Thank you very much,
    add-to-cart now goes smooth, but “remove-from-cart” still fires in console with

    Uncaught TypeError: Pinterest.tag is not a function
    at Object.fireEventForAllPixel (public.js?ver=11.2.1:564:53)

    You’re welcome. We’re checking on this and the fix will be released soon.

Viewing 6 replies - 1 through 6 (of 6 total)

You must be logged in to reply to this topic.