Support » Plugin: Smart Overlay » Javascript Error in WooCommerce Admin

  • Resolved Fencer04

    (@fencer04)


    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)
  • Plugin Support cornershop

    (@cornershop)

    Thanks for this heads up @fencer04 ! I’m having our devs take a look at what you’ve provided to see if we can fix this for all users.

    If there’s anything else you need, please don’t hesitate to let us know here or by emailing support@cshp.co

    Best,
    Monica

    Plugin Support cornershop

    (@cornershop)

    Thanks again for bringing this to our attention @fencer04 ! We’re incorporating a resolution into our new version of this plugin, which will be called WP Popup and will be released shortly!

    We really appreciate that you took the time to bring out attention to this.

    So if I update to the latest version of this plugin will it revert back to having the error or has this been fixed? The only thing I see in the changelog is ad admin notice about the new plugin.

    Plugin Support cornershop

    (@cornershop)

    Unfortunately, it’ll revert to having the error if you update. We’re fixing it on the new plugin since we’re moving away from this one.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Javascript Error in WooCommerce Admin’ is closed to new replies.