Javascript Error in WooCommerce Admin
-
I want to alert you to an error that is caused in the javascript admin when this plugin is active. The site is using WordPress 5.0.3 and WooCommerce 3.5.4. Both are the latest versions as of this post. When you try and access the variations of a product on the product admin page the are not displayed and there is the following javascript error:
Uncaught TypeError: Cannot read property 'replace' of undefined at CMB2ConditionalsFindDependants (cmb2-conditionals.js?ver=1.0.4:formatted:209) at HTMLSelectElement.<anonymous> (cmb2-conditionals.js?ver=1.0.4:formatted:41) at HTMLFormElement.dispatch (load-scripts.php?c=1&load[]=jquery-core,jquery-migrate,jquery-ui-core,jquery-ui-widget,jquery-ui-mouse,jquery-ui-sortable,utils&ver=0ab618a0c7f727035c000c0a569dc7a9:3) at HTMLFormElement.r.handle (load-scripts.php?c=1&load[]=jquery-core,jquery-migrate,jquery-ui-core,jquery-ui-widget,jquery-ui-mouse,jquery-ui-sortable,utils&ver=0ab618a0c7f727035c000c0a569dc7a9:3) at Object.trigger (load-scripts.php?c=1&load[]=jquery-core,jquery-migrate,jquery-ui-core,jquery-ui-widget,jquery-ui-mouse,jquery-ui-sortable,utils&ver=0ab618a0c7f727035c000c0a569dc7a9:3) at Object.a.event.trigger (load-scripts.php?c=1&load[]=jquery-core,jquery-migrate,jquery-ui-core,jquery-ui-widget,jquery-ui-mouse,jquery-ui-sortable,utils&ver=0ab618a0c7f727035c000c0a569dc7a9:9) at HTMLSelectElement.<anonymous> (load-scripts.php?c=1&load[]=jquery-core,jquery-migrate,jquery-ui-core,jquery-ui-widget,jquery-ui-mouse,jquery-ui-sortable,utils&ver=0ab618a0c7f727035c000c0a569dc7a9:3) at Function.each (load-scripts.php?c=1&load[]=jquery-core,jquery-migrate,jquery-ui-core,jquery-ui-widget,jquery-ui-mouse,jquery-ui-sortable,utils&ver=0ab618a0c7f727035c000c0a569dc7a9:2) at a.fn.init.each (load-scripts.php?c=1&load[]=jquery-core,jquery-migrate,jquery-ui-core,jquery-ui-widget,jquery-ui-mouse,jquery-ui-sortable,utils&ver=0ab618a0c7f727035c000c0a569dc7a9:2) at a.fn.init.trigger (load-scripts.php?c=1&load[]=jquery-core,jquery-migrate,jquery-ui-core,jquery-ui-widget,jquery-ui-mouse,jquery-ui-sortable,utils&ver=0ab618a0c7f727035c000c0a569dc7a9:3)
I was able to resolve this by editing the plugin function CMB2ConditionalsFindDependants in file /includes/CMB2-conditionals/cmb2-conditionals.js to:
function CMB2ConditionalsFindDependants( fieldName, elm, context ) { var inGroup, iterator; var dependants = []; if( typeof( fileName ) != "undefined" ) { // Remove the empty [] at the end of a multi-check field. fieldName = fieldName.replace( /\[\]$/, '' ); // Is there an element which is conditional on this element ? // If a group element, within the group. inGroup = elm.closest( '.cmb-repeatable-grouping' ); if ( 1 === inGroup.length ) { iterator = elm.closest( '[data-iterator]' ).data( 'iterator' ); dependants = $( '[data-conditional-id]', inGroup ).filter( function() { var conditionalId = $( this ).data( 'conditional-id' ); return ( Array.isArray( conditionalId ) && ( fieldName === conditionalId[0] + '[' + iterator + '][' + conditionalId[1] + ']' ) ); }); } // Else within the whole form. else { dependants = $( '[data-conditional-id="' + fieldName + '"]', context ); } } return dependants; }
Viewing 4 replies - 1 through 4 (of 4 total)
Viewing 4 replies - 1 through 4 (of 4 total)
- The topic ‘Javascript Error in WooCommerce Admin’ is closed to new replies.