• Resolved camryn2223

    (@camryn2223)


    I’ve installed the latest version of the plugin and a JavaScript error occurs on product pages when a user on the product isn’t a admin. The error occurs when a customer is logged in(as a non-admin) or is a guest and they’re on a product page. We do not compress or minify JavaScript files on our website. The error is shown in the browser console as:

    Uncaught TypeError: Cannot read properties of undefined (reading 'variation')
        at c (main.js?ver=315bdf9b03be89d6d841:1:700)
        at v (main.js?ver=315bdf9b03be89d6d841:1:1896)
        at main.js?ver=315bdf9b03be89d6d841:1:3701
        at document.body.onadded_to_cart (main.js?ver=315bdf9b03be89d6d841:1:4927)
        at Object.trigger (jquery.min.js?ver=3.7.1:2:70175)
        at HTMLBodyElement.<anonymous> (jquery.min.js?ver=3.7.1:2:70726)
        at Function.each (jquery.min.js?ver=3.7.1:2:3129)
        at e.<computed>.each (jquery.min.js?ver=3.7.1:2:1594)
        at e.<computed>.trigger (jquery.min.js?ver=3.7.1:2:70701)
        at Object.success (ajax-add-to-cart-button-public.js?ver=1.0.0:1:999)

    When I viewed the main.js file within the browser to investigate where exactly in the code the error is occurring I found it was happening at the line “return e.variation && (r.item_variant = e.variation) within the following code:

        const o = wcgai.config
          , r = window.wp.i18n
          , n = window.wp.hooks
          , c = (e,t)=>{
            var o;
            const r = {};
            return e.variation && (r.item_variant = e.variation),
            {
                item_id: s(e),
                item_name: e.name,
                ...m(e),
                quantity: null !== (o = e.quantity) && void 0 !== o ? o : t,
                price: a(e.prices.price, e.prices.currency_minor_unit),
                ...r
            }
        }

    Hopefully this can be fixed as this issue is breaking all the JavaScript that’s being ran on the product page.

    • This topic was modified 8 months, 3 weeks ago by camryn2223.
    • This topic was modified 8 months, 3 weeks ago by camryn2223.
Viewing 4 replies - 1 through 4 (of 4 total)
Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘JS Error On Product Page’ is closed to new replies.