简体   繁体   English

WooCommerce:删除产品写入面板选项卡

[英]WooCommerce: Removing product write panel tab

I'm using WooCommerce and I'd like to hide the "Linked Products" tab in the backend.我正在使用 WooCommerce,我想隐藏后端的“链接产品”选项卡。 I found a hook to add tabs ( woocommerce_product_write_panel_tabs ) but I'm not sure if it's also possible to hide certain tabs with this hook.我找到了一个添加标签的钩子( woocommerce_product_write_panel_tabs ),但我不确定是否也可以用这个钩子隐藏某些标签。

Thanks for any help!谢谢你的帮助!

产品写入面板选项卡

So I had the same issue.所以我有同样的问题。 Woocommerce provides a filter (just as they do about everything else) that can handle this. Woocommerce 提供了一个可以处理这个问题的过滤器(就像他们对其他所有事情所做的一样)。 The filter is 'woocommerce_product_data_tabs'.过滤器是“woocommerce_product_data_tabs”。

function remove_linked_products($tabs){
    unset($tabs['linked_product']);
    return($tabs);
}
add_filter('woocommerce_product_data_tabs', 'remove_linked_products', 10, 1);

This will remove the linked products tab.这将删除链接的产品选项卡。 You can also unset the other tabs using their array index.您还可以使用数组索引取消设置其他选项卡。 Below is a copy of the filter application from class-wc-meta-box-product-data.php.下面是来自 class-wc-meta-box-product-data.php 的过滤器应用程序的副本。

$product_data_tabs = apply_filters( 'woocommerce_product_data_tabs', array(
    'general' => array(
        'label'  => __( 'General', 'woocommerce' ),
        'target' => 'general_product_data',
        'class'  => array( 'hide_if_grouped' ),
    ),
    'inventory' => array(
        'label'  => __( 'Inventory', 'woocommerce' ),
        'target' => 'inventory_product_data',
        'class'  => array( 'show_if_simple', 'show_if_variable', 'show_if_grouped' ),
    ),
    'shipping' => array(
        'label'  => __( 'Shipping', 'woocommerce' ),
        'target' => 'shipping_product_data',
        'class'  => array( 'hide_if_virtual', 'hide_if_grouped', 'hide_if_external' ),
    ),
    'linked_product' => array(
        'label'  => __( 'Linked Products', 'woocommerce' ),
        'target' => 'linked_product_data',
        'class'  => array(),
    ),
    'attribute' => array(
        'label'  => __( 'Attributes', 'woocommerce' ),
        'target' => 'product_attributes',
        'class'  => array(),
    ),
    'variations' => array(
        'label'  => __( 'Variations', 'woocommerce' ),
        'target' => 'variable_product_options',
        'class'  => array( 'variations_tab', 'show_if_variable' ),
    ),
    'advanced' => array(
        'label'  => __( 'Advanced', 'woocommerce' ),
        'target' => 'advanced_product_data',
        'class'  => array(),
    )
));

So just substitute the unset($tabs['linked_product'] with whichever tab you want to remove from the backend.因此,只需将 unset($tabs['linked_product'] 替换为您要从后端删除的任何选项卡。

Adding the following to the wp-admin.min.css should remove the linked products.将以下内容添加到 wp-admin.min.css 应该删除链接的产品。

li.linked_product_options.linked_product_tab
{
    display:none !important;
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM