Top 5 Programming Questions and Answers Regarding WooCommerce Custom Tabs Part - 1
January 23, 2017,
Important Note: These are the answers provided by the community and best rated by the community as well.
.cat-item cat-item-17 current-cat cat-parent { color: #20dbfc!; }
.current-cat { color: #20dbfc!; }
He wants to it with PHP or JavaScript.pdf-icon::before { content: url(image.png) " "; }
Find PDF Links
href="page1.pdf">example1.pdf href="page1.pdf">example2.pdf href="page1.html">example3.html href="page1.pdf">example4.pdf
add_filter( 'woocommerce_product_tabs', 'woo_new_product_tab' ); function woo_new_product_tab( $tabs ) { // Adds the new tab $tabs['test_tab'] = array( 'title' => __( 'Features', 'woocommerce' ), 'priority' => 50, 'callback' => 'woo_new_product_tab_content' ); return $tabs; } function woo_new_product_tab_content() { // The new tab content $pa_value = get_post_meta( $product->id, 'pa_specification', true ); echo $pa_value; }
function woo_new_product_tab_content() { // The new tab content global $post; $product_id = $post->ID; $product = new WC_Product( $product_id ); $pa_value = $product->get_attribute('pa_specification'); echo $pa_value; }
add_action( 'woocommerce_single_product_summary', 'woocommerce_output_product_data_tabs', 60 );
This code will work for you but the formatting is a mess. Add custom CSS make desired tab function.add_action('woocommerce_after_shop_loop_item', 'woocommerce_output_product_data_tabs', 20);
He also edited as per LoicTheAztec reply to him. Below is his entire functions.php file. He tried it with ?> and without it at the bottom.// WooCommerce Tabs // REMOVE EXISTING TABS add_filter( 'woocommerce_product_tabs', 'woo_remove_product_tabs', 98 ); function woo_remove_product_tabs( $tabs ) { unset( $tabs['description'] ); // Remove the description tab // unset( $tabs['reviews'] ); // Remove the reviews tab unset( $tabs['additional_information'] ); // Remove the additional information tab return $tabs; } // ADD ATTRIBUTE DESCRIPTION TAB add_filter( 'woocommerce_product_tabs', 'woo_attrib_desc_tab' ); function woo_attrib_desc_tab( $tabs ) { // Adds the Attribute Description tab $tabs['attrib_desc_tab'] = array( 'title' => __( 'Desc', 'woocommerce' ), 'priority' => 100, 'callback' => 'woo_attrib_desc_tab_content' ); return $tabs; } // ADD QUANTITY PRICING TAB add_filter( 'woocommerce_product_tabs', 'woo_qty_pricing_tab' ); function woo_qty_pricing_tab( $tabs ) { // Adds the qty pricing tab $tabs['qty_pricing_tab'] = array( 'title' => __( 'Quantity Pricing', 'woocommerce' ), 'priority' => 110, 'callback' => 'woo_qty_pricing_tab_content' ); return $tabs; } // ADD OTHER PRODUCTS TAB add_filter( 'woocommerce_product_tabs', 'woo_other_products_tab' ); function woo_other_products_tab( $tabs ) { // Adds the other products tab $tabs['other_products_tab'] = array( 'title' => __( 'Other Products', 'woocommerce' ), 'priority' => 120, 'callback' => 'woo_other_products_tab_content' ); return $tabs; } // ADD CUSTOM TAB DESCRIPTIONS function woo_attrib_desc_tab_content() { // The attribute description tab content echo '
Description
'; echo 'Custom description tab.
'; } function woo_qty_pricing_tab_content() { // The qty pricing tab content echo 'Quantity Pricing
'; echo 'Here\'s your quantity pricing tab.
'; } function woo_other_products_tab_content() { // The other products tab content echo 'Other Products
'; echo 'Here\'s your other products tab.
'; }
php add_theme_support( 'builder-3.0' ); add_theme_support( 'builder-responsive' ); function register_my_fonts() { wp_register_style('googleFonts-OpenSans', '//fonts.googleapis.com/css?family=Open+Sans:400,300,700'); wp_enqueue_style( 'googleFonts-OpenSans'); } add_action('wp_enqueue_scripts', 'register_my_fonts'); function sc_replacecolon( $content ){ return str_replace( '[sc:', '[sc name=', $content ); } add_filter( 'the_content', 'sc_replacecolon', 5 ); /* WOOCOMMERCE */ add_filter( 'woocommerce_product_tabs', 'woo_custom_product_tabs', 100, 1 ); function woo_custom_product_tabs( $tabs ) { // 1) Removing tabs unset( $tabs['description'] ); // Remove the description tab // unset( $tabs['reviews'] ); // Remove the reviews tab unset( $tabs['additional_information'] ); // Remove the additional information tab // 2 Adding new tabs //Attribute Description tab $tabs['attrib_desc_tab'] = array( 'title' => __( 'Desc', 'woocommerce' ), 'priority' => 100, 'callback' => 'woo_attrib_desc_tab_content' ); // Adds the qty pricing tab $tabs['qty_pricing_tab'] = array( 'title' => __( 'Quantity Pricing', 'woocommerce' ), 'priority' => 110, 'callback' => 'woo_qty_pricing_tab_content' ); // Adds the other products tab $tabs['other_products_tab'] = array( 'title' => __( 'Other Products', 'woocommerce' ), 'priority' => 120, 'callback' => 'woo_other_products_tab_content' ); return $tabs; } // New Tab contents function woo_attrib_desc_tab_content() { // The attribute description tab content echo '
Description
'; echo 'Custom description tab.
'; } function woo_qty_pricing_tab_content() { // The qty pricing tab content echo 'Quantity Pricing
'; echo 'Here\'s your quantity pricing tab.
'; } function woo_other_products_tab_content() { // The other products tab content echo 'Other Products
'; echo 'Here\'s your other products tab.
'; } ?>
add_filter( 'woocommerce_product_tabs', 'woo_custom_product_tabs' ); function woo_custom_product_tabs( $tabs ) { // 1) Removing tabs unset( $tabs['description'] ); // Remove the description tab // unset( $tabs['reviews'] ); // Remove the reviews tab unset( $tabs['additional_information'] ); // Remove the additional information tab // 2 Adding new tabs //Attribute Description tab $tabs['attrib_desc_tab'] = array( 'title' => __( 'Desc', 'woocommerce' ), 'priority' => 100, 'callback' => 'woo_attrib_desc_tab_content' ); // Adds the qty pricing tab $tabs['qty_pricing_tab'] = array( 'title' => __( 'Quantity Pricing', 'woocommerce' ), 'priority' => 110, 'callback' => 'woo_qty_pricing_tab_content' ); // Adds the other products tab $tabs['other_products_tab'] = array( 'title' => __( 'Other Products', 'woocommerce' ), 'priority' => 120, 'callback' => 'woo_other_products_tab_content' ); return $tabs; } // New Tab contents function woo_attrib_desc_tab_content() { // The attribute description tab content echo '
Description
'; echo 'Custom description tab.
'; } function woo_qty_pricing_tab_content() { // The qty pricing tab content echo 'Quantity Pricing
'; echo 'Here\'s your quantity pricing tab.
'; } function woo_other_products_tab_content() { // The other products tab content echo 'Other Products
'; echo 'Here\'s your other products tab.
'; }
Download WooCommerce Custom Tabs