WordPress.org

Ready to get started?Download WordPress

Forums

WooCommerce - excelling eCommerce
[resolved] Adding new tabs and disabling default ones (5 posts)

  1. mompracem
    Member
    Posted 1 year ago #

    I need to add two new tabs to my products and remove the default tabs.

    For the latter problem I'm using Tab Manager extension.

    To add new tabs I'm using the following the following snipped with WooCommerce 2.02:

    function sg_woocommerce_map_tab() { 
    
        echo '<li><a href="#tab-new">' . __( 'My tab label', 'mytextdomain' ) . '</a></li>'; 
    
    }
    add_action( 'woocommerce_product_tabs', 'sg_woocommerce_map_tab', 40 );
    
    function sg_woocommerce_map_panel() { 
    
        require_once TEMPLATEPATH . 'parts/map.php';
        // I've tried also with include or commenting out the above line or using other code, no change in my issue
    
    }
    add_action( 'woocommerce_product_tab_panels', 'sg_woocommerce_map_panel', 40 );

    My issue is that, using the code above I get an infinite loop for the tab I'm trying to add on the product page. On the Tab Manager admin page (the third one, to select default tabs) I get a 404.

    Tried to contact WooCommerce support but after 13 days I'm still stuck.

    http://wordpress.org/extend/plugins/woocommerce/

  2. Roy
    Member
    Posted 1 year ago #

    2.0 uses filters to add/remove tabs not action. Please look through the first 5 pages of the support here, the correct method is listed.

  3. mompracem
    Member
    Posted 1 year ago #

    oh thanks eventually an answer of yours from this thread resolved it brilliantly http://wordpress.org/support/topic/adding-custom-product-tabs-to-201?replies=19

    I should have come up here rather than searching in WooCommerce support, my silly mistake to ignore WordPress forums as first choice to gather information...

    what I'm trying to understand now, is how to make one of the tabs I want to pass in the array conditional?

    eg suppose I have one tab which should appear only if the product (post) has a certain condition (such as a meta or other), how would you do that?

    I need to pass more than one tab.

    Thanks

  4. Roy
    Member
    Posted 1 year ago #

    Then you would probably need to retrieve the meta from the post so that it can be checked against.

    So I would imagine you need to pull in the global $post variable so you can find out which product you're on. And from the variable, you can use its methods to pull the meta information.

  5. mompracem
    Member
    Posted 1 year ago #

    oh in the meanwhile I figured out myself

    instead of placing the conditional inside the filter, I did inside tabs.php... essentially I put a conditional based on the $key in the foreach loop for tab and panel, works

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic