How do i create a new product tab
-
i need to create an additional product tab for the vendors to populate ‘About Brand’ – a block of text- on the product page alongside the STORES, DESCRIPTION, ETC
How do i do that?
-
You may use this plugin for the purpose – https://woocommerce.com/products/woocommerce-tab-manager/
@wclovers is that plugin the only option to show custom product tabs created on WCFM on our product pages? We should not have to spend an extra $100 if WCFM has the ability to create custom tabs. Is there any way to code the product page where the tabs created on WCFM show on the product page automatically?
would I be able to call the WCFM custom tabs to the product page using php with product data tabs from Woocommerce?
/**
* Customize product data tabs
*/
add_filter( ‘woocommerce_product_tabs’, ‘woo_custom_description_tab’, 98 );
function woo_custom_description_tab( $tabs ) {$tabs[‘description’][‘callback’] = ‘woo_custom_description_tab_content’; // Custom description callback
return $tabs;
}function woo_custom_description_tab_content() {
echo ‘<h2>Custom Description</h2>’;
echo ‘<p>Here\’s a custom description</p>’;
}add_action( ‘wcfmmp_rewrite_rules_loaded’, function( $wcfm_store_url ) {
add_rewrite_rule( $wcfm_store_url.’/([^/]+)/art_works?$’, ‘index.php?’.$wcfm_store_url.’=$matches[1]&art_works=true’, ‘top’ );
add_rewrite_rule( $wcfm_store_url.’/([^/]+)/art_works/page/?([0-9]{1,})/?$’, ‘index.php?’.$wcfm_store_url.’=$matches[1]&paged=$matches[2]&art_works=true’, ‘top’ );
}, 50 );add_filter( ‘query_vars’, function( $vars ) {
$vars[] = ‘art_works’;
return $vars;
}, 50 );add_filter( ‘wcfmmp_store_tabs’, function( $store_tabs, $store_id ) {
$store_tabs[‘art_works’] = ‘Art Works’;
return $store_tabs;
}, 50, 2 );add_filter( ‘wcfmp_store_tabs_url’, function( $store_tab_url, $tab ) {
if( $tab == ‘art_works’ ) {
$store_tab_url .= ‘art_works’;
}
return $store_tab_url;
}, 50, 2 );add_filter( ‘wcfmp_store_default_query_vars’, function( $query_var ) {
global $WCFM, $WCFMmp;if ( get_query_var( ‘art_works’ ) ) {
$query_var = ‘art_works’;
}
return $query_var;
}, 50 );add_filter( ‘wcfmmp_store_default_template’, function( $template, $tab ) {
if( $tab == ‘art_works’ ) {
$template = ‘store/wcfmmp-view-store-art-works.php’;
}
return $template;
}, 50, 2);-
This reply was modified 4 years, 4 months ago by
blackpassportstamps.
Where exactly you want to add custom tab? Under single product page or at store page?
Your code has both.
i placed it on the product page but it doesn’t show the content of the ABOUT BRAND,.
i followed your directions on how to get it done from your site and yet nothing shows out under the ABOUT BRAND which is to be the custom tabHey @wclovers, So the goal is for the custom tabs that are created in the Store vendor page, to show under specific tabs in the single product page.
If I create a custom ‘Trip schedule’ tab in store vendor page, I would like a new tab called ‘Trip schedule’ to show on the single product page with only information from that specific custom created tab in the store vendor page.
I would like to create 4 or 5 custom tabs to show like this.
I found a code to accomplish this, but it only works for one tab on the single product page by hiding the visibility of the custom tab created in the store vendor page.
add_filter( ‘woocommerce_product_tabs’, ‘woo_new_product_tab’ );
function woo_new_product_tab( $tabs ) {
$tabs[‘new_tab’] = array(
‘title’ => __( ‘My Tab’, ‘woocommerce’ ),
‘priority’ => 53,
‘callback’ => ‘woo_new_product_tab_content’
);
return $tabs;
}function woo_new_product_tab_content() {
global $WCFMu;
$product_id = get_the_ID();
if ( $product_id ) {
$wcfm_product_custom_fields = (array) get_option( ‘wcfm_product_custom_fields’ );
if ( $wcfm_product_custom_fields && is_array( $wcfm_product_custom_fields ) && ! empty( $wcfm_product_custom_fields ) ) {
$fields = ”;
foreach ( $wcfm_product_custom_fields as $wpcf_index => $wcfm_product_custom_field ) {
if ( ! isset( $wcfm_product_custom_field[‘enable’] ) )
continue;
$visibility = isset( $wcfm_product_custom_field[‘visibility’] ) ? $wcfm_product_custom_field[‘visibility’] : ”;
if ( $visibility )
continue; //we are not showing the fields that are allready visible in some other areas of the product
echo $WCFMu->wcfmu_customfield_support->get_wcfm_custom_field_display_data( $product_id, $wcfm_product_custom_field );
}
}
}
}— How can I create more than one custom tab to show on single product page?
add_filter( ‘woocommerce_product_tabs’, ‘woo_new_product_tab’ );
function woo_new_product_tab( $tabs ) {
$tabs[‘new_tab’] = array(
‘title’ => __( ‘My Tab’, ‘woocommerce’ ),
‘priority’ => 53,
‘callback’ => ‘woo_new_product_tab_content’
);
return $tabs;
}– Add more tabs here.
-
This reply was modified 4 years, 4 months ago by
- The topic ‘How do i create a new product tab’ is closed to new replies.