Admin: wc-enhanced-select.min.js Uncaught TypeError: Cannot read property ‘split
-
Hello folks,
I’ve developed several wordpress websites, some with woocommerce, most without. But I’ve encountered a problem with just one of them. Googling around gave me a few cases of people with the exact same problem but without a solution.
This error
wc-enhanced-select.min.js Uncaught TypeError: Cannot read property 'split' of null
appears when I try to edit a product in the admin and because of this error, all subsequent scripts are halted. Can’t add images or swap the tabs anymore, so its completely broken.I’ve loaded in the unminified version of this script to see what’s going wrong, and it’s this bit:
$( element.val().split( ',' ) ).each( function( i, val ) { selected.push({ id: val, text: data[ val ] }); });
In this case, it was checking one of the values with the ID #upsell_ids.
console.log($('#upsell_ids').val())
returns null (i made sure the element did exist, it just has an empty value), so the script is right to halt there.I’ve managed to fix it by wrapping it by an if to check if there is a value, like so:
if(element.val()){ $( element.val().split( ',' ) ).each( function( i, val ) { selected.push({ id: val, text: data[ val ] }); }); }
And it functions again. I hope this can help anyone. I’d like to know if this is good enough, or where i’m supposed to give this kind of feedback to woocommerce themselves. Their site is horrible, there is no way to come in contact with them if you never bought anything from them (well, we have, multiple times, for other clients, but I cant use those credentials). Even if its just a bug report (please correct me if im wrong).
So I’d like some advice how to fix this properly, or how it happens in the first place.
Much obliged.
- The topic ‘Admin: wc-enhanced-select.min.js Uncaught TypeError: Cannot read property ‘split’ is closed to new replies.