• Resolved mbasfour

    (@mbasfour)


    Whenever I try to add terms to a product attribute in product add page I get the following javascript error:

    load-scripts.php?c=0&load[]=jquery-core,jquery-migrate,utils,jquery-ui-core,jquery-ui-widget,jquery-ui-mouse,jquery-ui-sortable,underscore,backbone,wp-util,&load[]=wp-backbone,media-models,plupload&ver=4.8.1:59 Uncaught TypeError: Cannot read property 'replace' of undefined
    at Function.m.template (load-scripts.php?c=0&load[]=jquery-core,jquery-migrate,utils,jquery-ui-core,jquery-ui-widget,jquery-ui-mouse,jquery-ui-sortable,underscore,backbone,wp-util,&load[]=wp-backbone,media-models,plupload&ver=4.8.1:59)
    at load-scripts.php?c=0&load[]=jquery-core,jquery-migrate,utils,jquery-ui-core,jquery-ui-widget,jquery-ui-mouse,jquery-ui-sortable,underscore,backbone,wp-util,&load[]=wp-backbone,media-models,plupload&ver=4.8.1:63
    at HTMLButtonElement.<anonymous> (admin.js?ver=20170113:71)
    at HTMLBodyElement.dispatch (load-scripts.php?c=0&load[]=jquery-core,jquery-migrate,utils,jquery-ui-core,jquery-ui-widget,jquery-ui-mouse,jquery-ui-sortable,underscore,backbone,wp-util,&load[]=wp-backbone,media-models,plupload&ver=4.8.1:3)
    at HTMLBodyElement.r.handle (load-scripts.php?c=0&load[]=jquery-core,jquery-migrate,utils,jquery-ui-core,jquery-ui-widget,jquery-ui-mouse,jquery-ui-sortable,underscore,backbone,wp-util,&load[]=wp-backbone,media-models,plupload&ver=4.8.1:3)

    And the add term dialog don’t show, but the same functionality works in the edit product page.

    what can be the issue and how to fix it?

Viewing 1 replies (of 1 total)
  • Thread Starter mbasfour

    (@mbasfour)

    The problem was a minor bug in the plugin code, 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' ) )

Viewing 1 replies (of 1 total)
  • The topic ‘“Cannot read property ‘replace’ of undefined” error when trying to add attribute’ is closed to new replies.