“Cannot read property ‘replace’ of undefined” Javascript error when trying to add attribute terms from add product page [closed]

The problem was a minor bug in the Variation Swatches for WooCommerce plugin, the add term modal html wasn’t being included in the add product page as a result of wrong conditional statement in the class-admin.php file on line 266:

if ( $pagenow != 'post.php' || ( isset( $post ) && get_post_type( $post->ID ) != 'product' ) )

This condition doesn’t check for the add product page so to fix it we need to add the post-new.php page as an accepted page using this statement:

if ( ($pagenow != 'post.php' && $pagenow != 'post-new.php') || ( isset( $post ) && get_post_type( $post->ID ) != 'product' ) )