Add a New Tab in Vendor Dash Product Editor

This snippet is what I use to add an additional tab to my product editor for information, text only. My site has several third party plugins which enable extra functionality that I have not had the time or budget to integrate into the vendor dashboard, so I just add a note in an Extra Features tab to let them know what I can do for them if they ask.

Huge lesson learned: The base code for this is provided on the WCMp website, where they give a much more complicated example on adding input fields that get saved and everything. For some reason, that code is set up to override the Advanced tab instead of creating an actual new one–which is accomplished just by naming it something else. If you use this code to remove the Advanced tab and then later try adding your own, it won’t display and that’s why. I’m not ready to talk about how many hours that took to figure out.

As always, this is either added to your Child Theme’s functions.php file, or consider using the My Custom Functions Pro plugin to manage and organize all your snippets.

// NOTE:  THE CODE PROVIDED BY WCMP TO ADD YOUR OWN NEW TAB HERE CURRENTLY IS SET TO OVERWRITE THE ADVANCED TAB.  HAVING THIS CODE HERE MAKES IT SO YOUR NEW TAB WILL NEVER SHOW UP.  ASK ME HOW MANY HOURS WERE SPENT FIGURING THAT OUT.

/**
* Add Custom Tab in add product page.
* @author WC Marketplace
* @Version 3.3.0
*/
function add_custom_product_data_tabs_2( $tabs ) {
   // THE DEFAULT CODE GIVEN BY WCMP HAS THE WORD ADVANCED WHERE I HAVE EXTRAS.  DONT USE ADVANCED HERE IF YOU MAY HAVE UNSET YOUR ADVANCED TAB WITH ANOTHER SNIPPET.
   $tabs['extras'] = array(
       'label'    => __( 'Extra Features', 'your-text-domain' ),
       'target'   => 'custom_tab_product_data_adv',
       'class'    => array(),
       'priority' => 100,
   );
   return $tabs;
}
add_filter( 'wcmp_product_data_tabs', 'add_custom_product_data_tabs_2' );

/**
* Add Custom Tab content in add product page.
* @author WC Marketplace
* @Version 3.3.0
*/
function add_custom_product_data_content_2( $pro_class_obj, $product, $post ) {
    //prnt_r($product->get_id());die;
    $hh = get_post_meta($product->get_id() , '_custom_text_field' );
    //print_r($hh);
   ?>
   <div role="tabpanel" class="tab-pane fade" id="custom_tab_product_data_adv"> <!-- just make sure tabpanel id should replace with your added tab target -->
       <div class="row-padding">
           <h4 style="line-height: 1.4"><strong>Additional Customization Options Not Available in Dashboard</strong></h4>
           <h4 style="line-height: 1.4;">We have several features available which are not integrated into this dashboard due to the cost of custom code work.  If you would like to utilize any of these features, it just requires the Site Admin to set them up on your behalf.  In that case, please choose the option to submit for review and provide your comments.</h4>
           <h4 style="line-height: 1.4;">Options include:  Quantity discounts, Min or Max Allowed Quantities, Special Offers (i.e. buy 10 of X and get Y free), and Automatically Added Coupons.</h4>
           <h4 style="line-height: 1.4;">See the <a href="https://example.com/vendor-dashboard/vendor-knowledgebase" target="blank">Knowledgebase</a> for more detailed explanations and screen shot examples, but please don't hesitate to ask in case you don't understand this or if you have a unique sitation.</h4>
       </div>
   </div>
   <?php
}
add_action( 'wcmp_product_tabs_content', 'add_custom_product_data_content_2', 10, 3 );

Is this no longer relevant or not working? Please let us know in the comments!

Comments on this post

Your email address will not be published. Required fields are marked *