Woocommerce 将自定义javascript添加到编辑产品页面

Woocommerce 将自定义javascript添加到编辑产品页面,woocommerce,Woocommerce,如何仅将自定义js文件引用到Woocommerce编辑/添加产品页面 提前谢谢 Ciao这对我很有用(将添加到themes的functions.php文件中): //wholesale-prices function add_admin_scripts( $hook ) { global $post; if ( $hook == 'post-new.php' || $hook == 'post.php' ) { if ( 'product' === $post

如何仅将自定义js文件引用到Woocommerce编辑/添加产品页面

提前谢谢

Ciao

这对我很有用(将添加到themes的functions.php文件中):

//wholesale-prices
function add_admin_scripts( $hook ) {

    global $post;

    if ( $hook == 'post-new.php' || $hook == 'post.php' ) {
        if ( 'product' === $post->post_type ) {     
            wp_enqueue_script(  'myscript', get_stylesheet_directory_uri().'/js/wholesale-prices.js' );
        }
    }
}
add_action( 'admin_enqueue_scripts', 'add_admin_scripts', 10, 1 );