首页 文章

在woocommerce产品类型中隐藏选项选择项目

提问于
浏览
3

我打算向某人提供一个woocommerce商店,我想隐藏所有必要的选项,以免混淆非高级用户 . 特别是产品类型 .

在WooCommerce产品编辑器中,可以选择产品类型 . 我只想展示简单和可变的产品 .

通常这可以使用css display:hide属性来完成,但是当我检查woocommerce产品选项时,选项没有id或类选择器 .

这是我在产品选项上看到的代码

<select id="product-type" name="product-type">
<optgroup label="Product Type"><option value="simple" selected="selected">Simple product</option>
<option value="grouped">Grouped product</option><option value="external">External/Affiliate product</option>
<option value="variable">Variable product</option></optgroup>
</select>

我的问题 . 有没有办法在一个选项框中隐藏分组产品和联盟产品类型,以便在woocommerce或wp更新期间不会受到影响?

谢谢

2 回答

  • 16

    你可以过滤 product_type_selector

    add_filter( 'product_type_selector', 'remove_product_types' );
    
    function remove_product_types( $types ){
        unset( $types['grouped'] );
        unset( $types['external'] );
    
        return $types;
    }
    
  • 3

    您可以使用命名选择器:

    #product-type option[value="grouped"] {
        ... your css here ...
    }
    

    看这篇文章:CSS to select another Element based on a HTML Select Option Value

相关问题