doutuobao4004 2018-12-11 21:13
浏览 122
已采纳

隐藏Woocommerce中产品变体设置的重量和尺寸字段

I am working on a website that does not need the shipping weight and dimensions in WooCommerce. On the admin area - when adding a new product, there is the shipping tab which has this option. Is there a way to hide it? I tried using the following CSS but it did not work. I have been looking for a way to use my functions.php file to remove it but cannot figure out how. Here is what I tried:

p.form-field._weight_field {display:none;}

p.form-field .dimensions_field {display:none;}

.woocommerce_options_panel .options_group:first-child{display:none 
!important;}

I tried that in multiple variations with no luck. Does anyone know of a way to use the functions.php file and hide just the weight and dimensions input area?

  • 写回答

2条回答 默认 最新

  • dpzzkfb1244 2018-12-11 23:49
    关注

    Hiding product weight and dimensions fields in Admin product pages settings.

    1) For product post type you will use:

    // Products
    add_action( 'woocommerce_product_options_general_product_data', 'hide_product_weight_and_dimentions' );
    function hide_product_weight_and_dimentions(){
        ?><style>
            div#shipping_product_data ._weight_field, div#shipping_product_data .dimensions_field { display:none !important;}
        </style><?php
    }
    

    2) For Product variations you will use:

    // Variations
    add_action( 'woocommerce_variation_options_pricing', 'hide_variation_weight_and_dimentions', 10, 3 );
    function hide_variation_weight_and_dimentions( $loop, $variation_data, $variation ){
        ?><style>
            .variable_weight<?php echo $loop ?>_field, .dimensions_field { display:none !important;}
        </style><?php
    }
    

    Code goes in function.php file of your active child theme (or active theme). Tested and works.

    On a simple product:

    enter image description here

    On a product variation from a variable product:

    enter image description here

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 banner广告展示设置多少时间不怎么会消耗用户价值
  • ¥16 mybatis的代理对象无法通过@Autowired装填
  • ¥15 可见光定位matlab仿真
  • ¥15 arduino 四自由度机械臂
  • ¥15 wordpress 产品图片 GIF 没法显示
  • ¥15 求三国群英传pl国战时间的修改方法
  • ¥15 matlab代码代写,需写出详细代码,代价私
  • ¥15 ROS系统搭建请教(跨境电商用途)
  • ¥15 AIC3204的示例代码有吗,想用AIC3204测量血氧,找不到相关的代码。
  • ¥20 CST怎么把天线放在座椅环境中并仿真