2016-12-28 15 views

答えて

1

これは、特定の単一の製品にWooCommerceタブを削除することは非常に簡単です。 CSSを使って簡単にこれを行うことができます。すべてのWC製品には固有の製品IDがありますので、http://prntscr.com/dp2c79にチェックを入れてください。ブラウザのinspect要素またはソースコードを使用してください。 商品IDを見つけて、その商品IDに「表示:なし」タブを使用してください。

例:#製品-834 .tabs {表示:なし重要;}上の

よろしく、

2

のみ一部の製品のためのタブを削除するには、専用のwoocommerce_product_tabsフィルターフックを使用することは可能です(単一の製品ページ):

add_filter('woocommerce_product_tabs', 'conditionaly_removing_product_tabs', 98); 
function conditionaly_removing_product_tabs($tabs) { 

    // Get the global product object 
    global $product; 

    // Get the current product ID 
    $product_id = method_exists($product, 'get_id') ? $product->get_id() : $product->id; 

    // Define HERE your targetted products IDs in this array <=== <=== <=== 
    $target_products_ids = array(123,152,162); 

    // If the current product have the same ID than one of the defined IDs in your array,… 
    // we remove the tab. 
    if(in_array($product_id, $target_products_ids)){ 

     // KEEP BELOW ONLY THE TABS YOU NEED TO REMOVE <=== <=== <=== <=== 
     unset($tabs['description']); // (Description tab) 
     unset($tabs['reviews']);  // (Reviews tab) 
     unset($tabs['additional_information']); // (Additional information tab)  
    } 

    return $tabs; 

} 

コードは、あなたのアクティブCHILのfunction.phpファイルに行きますdテーマ(アクティブなテーマまたはプラグインファイル)。

このコードはテスト済みであり、動作します。

オリジナルのWooCommerceスニペットに基づく:Editing product data tabs

関連する問題