【问题标题】:Add custom javascript to Woocommerce edit product page将自定义 javascript 添加到 Woocommerce 编辑产品页面
【发布时间】:2018-12-20 00:08:38
【问题描述】:

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

提前致谢。

【问题讨论】:

    标签: woocommerce


    【解决方案1】:

    这对我有用(将添加到主题的 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 );
    

    【讨论】:

      猜你喜欢
      • 2020-01-20
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-07-06
      • 1970-01-01
      • 1970-01-01
      • 2022-01-22
      • 1970-01-01
      相关资源
      最近更新 更多