Title: JavaScript error in admin_footer: Identifier &#8216;fields&#8217; already declared
Last modified: June 22, 2026

---

# JavaScript error in admin_footer: Identifier ‘fields’ already declared

 *  [vincyxir](https://wordpress.org/support/users/vincyxir/)
 * (@vincyxir)
 * [2 weeks ago](https://wordpress.org/support/topic/javascript-error-in-admin_footer-identifier-fields-already-declared/)
 *     ```wp-block-code
       Hi QuadLayers team,I ran into a JavaScript issue with Checkout Field Manager / WooCommerce Checkout Manager.Here’s what’s happening:In the plugin file lib/class-plugin.php, there’s a function called Plugin::add_premium_style(). The code looks like this:<script>    const fields = document.querySelectorAll('.wooccm-premium-field')    Array.from(fields).forEach((field) => {        field.closest('tr')?.classList.add('wooccm-premium-field');    })</script>The problem is, this script gets printed in the admin_footer. On some WooCommerce admin pages—especially the products screen or the import page—it throws a browser console error:Uncaught SyntaxError: Identifier 'fields' has already been declaredIn my setup, this actually stopped the WooCommerce product import progress bar from working.Here’s my suggested fix: wrap that JS code in an IIFE and use a less generic variable name at the top level. For example:<script>(function () {    var wooccmPremiumFields = document.querySelectorAll('.wooccm-premium-field');    Array.prototype.forEach.call(wooccmPremiumFields, function (field) {        var row = field.closest('tr');        if (row) {            row.classList.add('wooccm-premium-field');        }    });})();</script>This does the same thing as before, but keeps those variables out of the global scope. That way, you avoid conflicts with other admin scripts.I tried this change locally, and it fixed the JavaScript error. The WooCommerce import progress bar worked again.Thanks!
       ```
   

You must be [logged in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fwordpress.org%2Fsupport%2Ftopic%2Fjavascript-error-in-admin_footer-identifier-fields-already-declared%2F%3Foutput_format%3Dmd&locale=en_US)
to reply to this topic.

 * ![](https://ps.w.org/woocommerce-checkout-manager/assets/icon-256x256.jpg?rev
   =2911736)
 * [Checkout Field Manager (Checkout Manager) for WooCommerce](https://wordpress.org/plugins/woocommerce-checkout-manager/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/woocommerce-checkout-manager/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/woocommerce-checkout-manager/)
 * [Active Topics](https://wordpress.org/support/plugin/woocommerce-checkout-manager/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/woocommerce-checkout-manager/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/woocommerce-checkout-manager/reviews/)

## Tags

 * [checkout manager](https://wordpress.org/support/topic-tag/checkout-manager/)
 * [javascript](https://wordpress.org/support/topic-tag/javascript/)
 * [woocommerce import](https://wordpress.org/support/topic-tag/woocommerce-import/)

 * 0 replies
 * 1 participant
 * Last reply from: [vincyxir](https://wordpress.org/support/users/vincyxir/)
 * Last activity: [2 weeks ago](https://wordpress.org/support/topic/javascript-error-in-admin_footer-identifier-fields-already-declared/)
 * Status: not resolved