Home Forums WoodMart support forum _.template is not a function on variable product pages – triggered only by mouse

_.template is not a function on variable product pages – triggered only by mouse

Viewing 1 post (of 1 total)
  • Author
    Posts
  • #725813

    marcosrjdesouza
    Participant

    Subject: _.template is not a function on variable product pages — triggered only by mouse interaction

    Hello,

    I’m having a JavaScript error on variable product pages that breaks the variation form rendering and causes a visible layout shift.

    Site: innovcable.com.br
    Example URL: https://innovcable.com.br/produto/cabo-de-instrumentacao-blindado-em-fita-individual-e-coletiva-bfic-300v-nbr-10300/

    The behavior

    The key detail: the error only fires when the mouse moves over the page.

    Without any mouse interaction: the page loads completely and correctly. Product code, variation swatches, and the B2BKing tiered pricing table all render. No errors in console.
    As soon as I move the mouse anywhere on the page: the error below is thrown, the variation block fails to render, and the page content shifts (Forced reflow while executing JavaScript took 36ms).

    This is reproducible on every variable product on the site.

    The error
    Uncaught TypeError: _.template is not a function
    at wp-util.min.js:2:342
    at r.onFoundVariation (add-to-cart-variation.min.js:1:6833)
    at HTMLFormElement.dispatch (jquery.min.js:2:40035)
    at v.handle (jquery.min.js:2:38006)
    at Object.trigger (jquery.min.js:2:70124)
    at HTMLFormElement.<anonymous> (jquery.min.js:2:70726)
    at ce.each (jquery.min.js:2:3129)
    at e.<computed>.each (jquery.min.js:2:1594)
    at e.<computed>.trigger (jquery.min.js:2:70701)
    at Object.success (add-to-cart-variation.min.js:1:5470)
    What I’ve already verified

    Confirmed with LiteSpeed Cache fully deactivated. I deactivated the LiteSpeed Cache plugin entirely and reloaded the page. The error occurred against the original, unmodified core files — wp-util.min.js?ver=7.0.3, add-to-cart-variation.min.js?ver=11.0.0, and jquery.min.js?ver=3.7.1 — with the standard ?ver= query strings and no minification or concatenation applied. The error was identical (wp-util.min.js:2:342), which rules out any caching or asset-optimization layer.

    Underscore is loaded and working. Running typeof _ in the console returns ‘function’, and the Network tab shows underscore.min.js loading successfully (status 200, 7.6 kB). So this is not a missing dependency — the error happens even though _ is available globally at that point.

    Tested every relevant LiteSpeed configuration before deactivating it: Combine JS disabled, Load JS Deferred disabled, Load JS Delayed never enabled, Guest Mode disabled, Minify JS tested both on and off. The error persisted in all configurations.

    Not an asset-unloading issue. I use Asset CleanUp, and it has zero unload rules for the product post type (confirmed under Bulk Changes → product). Nothing is being removed from product pages.

    Not a CSS issue. CLS measures 0.06 in Chrome DevTools. The visual jump is caused by the failed render and reflow, not by unstyled content.

    Environment
    WoodMart theme with Elementor single-product template
    Variation swatches enabled
    B2BKing (tiered pricing table on product page)
    YITH WooCommerce Product Add-ons
    WooCommerce 11.0.0, WordPress 7.0.3, jQuery 3.7.1
    Variable products using default attributes
    Why I believe this is theme-related

    The stack trace shows onFoundVariation — a WooCommerce handler — failing inside wp-util. Since Underscore is confirmed present in global scope, something appears to be affecting the scope or execution context in which that handler runs. Given that the trigger is a mouse event, I suspect the WoodMart swatch handlers (wd-swatches-variations, wd-variations-price) may be re-triggering the variation form in a context where _ isn’t resolvable.

    Could you advise whether this is a known conflict, and whether there’s a recommended configuration or patch?

    Thank you.

Viewing 1 post (of 1 total)