Add secondary attributes tab to woocommerce - wordpress

I need to add another tab to product tabs section of woocommerce with the name of features and it's content fills just like attributes section. the source be same but data store in separate meta data and show it in another tab in product page view section.
any Idea how should to do this?
thank you in advance

Here is my code
add_filter( 'woocommerce_product_tabs', 'woo_new_product_tab' );
function woo_new_product_tab( $tabs ) {
$tabs['featurestab'] = array(
'title' => __( 'Features', 'woocommerce' ),
'priority' => 15,
'callback' => 'features_tab_content');
return $tabs;
}
function features_tab_content() {
echo 'Your product ('.get_the_ID().') features.';
}

Related

Adding extra tabs to woocommerce single product

Hi i wish to add extra tabs to woocommerce single product. I have seen the code below which works but every product has the same tab, is there a way where i can select products where the tab would show as i want the same info on multiple products but not all products.
/**
* Add a custom product data tab
*/
add_filter( 'woocommerce_product_tabs', 'woo_new_product_tab' );
function woo_new_product_tab( $tabs ) {
// Adds the new tab
$tabs['test_tab'] = array(
'title' => __( 'New Product Tab', 'woocommerce' ),
'priority' => 50,
'callback' => 'woo_new_product_tab_content'
);
return $tabs;
}
function woo_new_product_tab_content() {
// The new tab content
echo '<h2>New Product Tab</h2>';
echo '<p>Here\'s your new product tab.</p>';
}

WooCommerce Custom Product Tab: Don't display on certain product pages

I've got a custom product tab that should appear first (over the Long Description) in my tab lineup. Problem is two of the products should not be seeing this tab at all. So I did a display: none; for that custom tab in CSS for those pages, which worked, but then you see no content in what becomes the first product tab, the long description.
So realistically, that doesn't work. It's just a band aid. So can I add some kind of an if statement to this?
add_filter( 'woocommerce_product_tabs', 'woo_new_product_tab1' );
function woo_new_product_tab1( $tabs1 ) {
// Adds the new tab
$tabs1['shade_tab'] = array(
'title' => __( 'Product Tab Name', 'woocommerce' ),
'priority' => 100,
'callback' => 'woo_new_product_tab_content1'
);
return $tabs1;
}
Try the below code, change 11 and 12 to your products ID's
add_filter( 'woocommerce_product_tabs', 'woo_new_product_tab1' );
function woo_new_product_tab1( $tabs1 ) {
global $product;
// Adds the new tab
if( !$product->get_id() == 11 && !$product->get_id() == 12 ){
$tabs1['shade_tab'] = array(
'title' => __( 'Product Tab Name', 'woocommerce' ),
'priority' => 100,
'callback' => 'woo_new_product_tab_content1'
);
}
return $tabs1;
}
Here's the solution. Ahmad was close but the line should be:
if( ! in_array( $product->get_id(), array( 232, 280 ) ) ){

Woocommerce product tabs (show other products)

I am using woo commerce in my wordpress store online, I got a requirement that when a product is clicked and we navigate to the product detail page. I need to show the tabs into the product page like in the link
http://www.designbyhumans.com/shop/t-shirt/men/wolf-i/17011/
In this link two additional tabs are shown
1. Phone Cases
2. Art prints
Is there any way to achieve this is woo commerce?
Please help.
You can add custom tabs using woocommerce filters
The below code adds an extra tab called 'Product Description'.
add_filter( 'woocommerce_product_tabs', 'woo_new_product_tab' );
function woo_new_product_tab( $tabs ) {
// Adds the new tab
$tabs['desc_tab'] = array(
'title' => __( 'Product Description', 'woocommerce' ),
'priority' => 50,
'callback' => 'woo_new_product_tab_content'
);
}
function woo_new_product_tab_content() {
// The new tab content
$prod_id = get_the_ID();
echo '<p>'.get_post_meta($prod_id,'product_description',true).'</p>';
}
You would need to fetch the product data into these tabs. In the above example data from a custom field(product_description) is fetched into the tab.

how can i display product's custom field in wp-admin/edit.php?post_type=product ( product listing table in admin ) woocommerce

I have added some custom fields in woocommerce when adding product. Now i want to display those custom fields in product listing page ( wp-admin/edit.php?post_type=product ). I also want to quick edit and save like other values can be edit and save in listing page.
I tried bellow code but it did not work.
add_filter( 'manage_edit-product', 'show_product_order' );
function show_product_order($columns){
$new_columns = (is_array($columns)) ? $columns : array();
unset( $new_columns['order_actions'] );
$new_columns['product_order'] = 'Product Order';
$new_columns['order_actions'] = $columns['order_actions'];
return $new_columns;
}
I also tried below code but it did not worked too.
add_action( 'woocommerce_product_options_general_product_data', 'woocommerce_general_product_data_custom_field' );
function woocommerce_general_product_data_custom_field() {
global $woocommerce, $post;
echo '<div class="options_group">';
woocommerce_wp_checkbox(
array(
'id' => 'product_order',
'wrapper_class' => 'checkbox_class',
'label' => __('Order for Product', 'woocommerce' ),
'description' => __( 'Order for Product', 'woocommerce' )
)
);
echo '</div>';
}
i also reffered this post WooCommerce show custom column but i did not succeed to get solution
Please help.

Adding User Profile Fields to Wordpress Buddypress to Include "Favorites"

I'm trying to figure out a way for members on my Wordpress (Buddypress) site to pick their "favorite movies, books, etc."
It would be nice if, instead of members simply typing a list of these things, they could select from books already in the system, and add more as the please in the future.
I'm hoping that there is an easy answer to this, such as a plugin that I can use, or, at least, modify. Does anyone know of anything that I can look into?
Your title asks how to add a user profile field. Here is the code to add as many fields as you like. Once you add the field, you can easily place additional inputs or options on the custom tab page for users to enter their own favorites.
function my_test_setup_nav() {
global $bp;
$parent_slug = ‘test’;
$child_slug = ‘test_sub’;
//name, slug, screen, position, default subnav
bp_core_new_nav_item( array(‘name’ => __( ‘Test’ ),’slug’ => $parent_slug,’screen_function’ => ‘my_profile_page_function_to_show_screen’,'position’ => 40,’default_subnav_slug’ => $child_slug ) );
/* Add the subnav items to the profile */
// name, slug, parent_url, parent slug, screen function
bp_core_new_subnav_item( array( ‘name’ => __( ‘Home’ ), ‘slug’ => $child_slug, ‘parent_url’ => $bp->loggedin_user->domain . $parent_slug.’/', ‘parent_slug’ => $parent_slug, ‘screen_function’ => ‘my_profile_page_function_to_show_screen’ ) );
bp_core_new_subnav_item( array( ‘name’ => __( ‘Random Page’ ), ‘slug’ => ‘random’, ‘parent_url’ => $bp->loggedin_user->domain . $parent_slug.’/', ‘parent_slug’ => $parent_slug, ‘screen_function’ => ‘my_profile_page_function_to_show_screen234′ ) );
}
function my_profile_page_function_to_show_screen() {
//add title and content here – last is to call the members plugin.php template
add_action( ‘bp_template_title’, ‘my_profile_page_function_to_show_screen_title’ );
add_action( ‘bp_template_content’, ‘my_profile_page_function_to_show_screen_content’ );
bp_core_load_template( apply_filters( ‘bp_core_template_plugin’, ‘members/single/plugins’ ) );
}
function my_profile_page_function_to_show_screen_title() {
echo ‘wptaskforce title’;
}
function my_profile_page_function_to_show_screen_content() {
echo ‘wptaskforce content’;
}
//random page content:
function my_profile_page_function_to_show_screen234() {
//add content here – last is to call the members plugin.php template
add_action( ‘bp_template_content’, ‘my_profile_page_function_to_show_screen234_content’ );
bp_core_load_template( apply_filters( ‘bp_core_template_plugin’, ‘members/single/plugins’ ) );
}
function my_profile_page_function_to_show_screen234_content() {
echo ‘This is a random page.’;
}
add_action( ‘bp_setup_nav’, ‘my_test_setup_nav’ );

Resources