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

    (@babylon1999)

    Hello @joshdb,

    Thank you for reaching out!

    I see this was previously reported to the developers here, but the team wasn’t able to reproduce it.

    Can you please confirm if you see the same behaviour with only WooCommerce active and the default Storefront theme?

    Look forward to hearing back from you.

    Thread Starter joshdb

    (@joshdb)

    @saif

    When activating the Storefront?theme and testing again, I receive the same error.

    I should mention I get two other types of errors that occur on page load:

    • Uncaught ReferenceError: jQuery is not defined wp-util.min.js?ver=6.4.2:2
    • There are also a bunch of errors related to Kaspersky, but those all seem related to CSS.

    Oddly enough the first error which occurs 3 times (one from the aforementioned file and twice inline) is followed by:

    JQMIGRATE: Migrate is installed, version 3.4.1 jquery-migrate.min.js?amp;ver=3.4.1:2

    This error occurs regardless of the selected theme. It seems like it may be related to the original error, but I’m unsure.

    Thread Starter joshdb

    (@joshdb)

    I’d also like to add that when viewing the site while logged into the WordPress admin panel and previewing the site, the “Uncaught TypeError” and “Uncaught ReferenceError” do not occur.

    Plugin Support Shameem R. a11n

    (@shameemreza)

    Hi @joshdb,

    The “Uncaught TypeError: wp.template is not a function” error you’re encountering seems to be related to a JavaScript conflict. This could be due to a number of reasons, such as plugin conflicts, outdated versions of WordPress or WooCommerce, or issues with your theme.

    Since you’ve already tried disabling plugins and switching themes, it’s possible that the issue might be with the WordPress or WooCommerce versions you are using. Please make sure both are updated to their latest versions.

    The “Uncaught ReferenceError: jQuery is not defined” error suggests that jQuery might not be loading correctly on your site. This could also be a source of the problem. You could try re-uploading the wp-includes and wp-admin directories from a fresh WordPress install.

    If the issue persists, I recommend contacting the theme developer or hiring a developer to look into this further.

    Please note that while viewing the site and logging into the WordPress admin panel, certain scripts may not be loaded, which could explain why the errors do not occur in that case.

    I hope this provides some clarity. Please let us know if you have any other questions.

    Thread Starter joshdb

    (@joshdb)

    TL;DR

    Speed Optimizer 7.4.4 by SiteGround is the problem.

    Versions

    • WordPress: 6.4.2
    • WooCommerce: 8.3.1
    • WooCommerce – ShipStation Integration: 4.3.9
    • WooCommerce – Shipping and Tax: 2.4.2
    • WooPayments: 6.9.1

    wp-includes and wp-admin directories deleted then replaced from a fresh WordPress install did not have any effect.

    I took a look at where jquery scripts are being loaded and they are in the body tag after the page content grouped with other script tags. The domain replaced with “[domain.com]”.

    <script defer type="text/javascript" src="https://[domain.com]/wp-includes/js/jquery/jquery.min.js?amp;ver=3.7.1" id="jquery-core-js"></script>
    <script defer type="text/javascript" src="https://[domain.com]/wp-includes/js/jquery/jquery.min.js?amp;ver=3.7.1" id="jquery-core-js"></script>
    <script defer type="text/javascript" src="https://[domain.com]/wp-includes/js/jquery/jquery-migrate.min.js?amp;ver=3.4.1" id="jquery-migrate-js"></script>

    I see that they have the defer attribute, but that might not guarantee that the scripts load in time for other scripts.

    <script defer type="text/javascript" src="https://stats.wp.com/w.js?amp;ver=202349" id="woo-tracks-js"></script>

    The above script appears just before the aforementioned jquery scripts, while all other WooCommerce scripts appear after the jquery scripts.

    I went through all my plugins again disabling them one at a time as before and found that the following plugin was the issue:

    Speed Optimizer 7.4.4 by SiteGround

    Do not use this plugin if you are also using WooCommerce.

    When this plugin is disabled, a group of script tags (including the 3 jquery script tags) are now located in the head tag instead of the body tag and they no longer have the defer attribute.

    @saif

    Thank you for your help. Your insights pushed me to better understand what was going on, investigate and understand why the issue was occurring.

    Saif

    (@babylon1999)

    Glad to hear you were able to figure it out. Well done, @joshdb! :?)

    Also, thank you so much for sharing the solution with the community!

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Woocommerce add to cart button error: wp.template is not a function’ is closed to new replies.