Support

Account

Home Forums General Issues Can't get WooCommerce tab to display

Helping

Can't get WooCommerce tab to display

  • Hi, please don’t shoot me down, my PHP skills are fairly basic and I’m doing my best but need some help. I’m trying to create some custom tabs for WooCommerce using ACF but I’m not able to get them to show in the front end. This is how I have created my tabs:

    
    if( function_exists('acf_add_local_field_group') ):
    
    acf_add_local_field_group(array(
    	'key' => 'group_5d7b1a26f0537',
    	'title' => 'Product Options',
    	'fields' => array(
    		array(
    			'key' => 'field_5dee0ddd81ab4',
    			'label' => 'Tabs',
    			'name' => 'product_tab_list',
    			'type' => 'repeater',
    			'instructions' => '',
    			'required' => 0,
    			'conditional_logic' => 0,
    			'wrapper' => array(
    				'width' => '',
    				'class' => '',
    				'id' => '',
    			),
    			'collapsed' => '',
    			'min' => 0,
    			'max' => 0,
    			'layout' => 'table',
    			'button_label' => 'Add Product Tab',
    			'sub_fields' => array(
    				array(
    					'key' => 'field_5dee0df781ab6',
    					'label' => 'Content',
    					'name' => 'tab_content',
    					'type' => 'textarea',
    					'instructions' => '',
    					'required' => 0,
    					'conditional_logic' => 0,
    					'wrapper' => array(
    						'width' => '',
    						'class' => '',
    						'id' => '',
    					),
    					'default_value' => '',
    					'placeholder' => '',
    					'maxlength' => '',
    					'rows' => '',
    					'new_lines' => 'wpautop',
    				),
    				array(
    					'key' => 'field_5dee0dea81ab5',
    					'label' => 'Title',
    					'name' => 'tab_title',
    					'type' => 'text',
    					'instructions' => 'PDF Brochure / Parts / Video / Other tab titles',
    					'required' => 0,
    					'conditional_logic' => 0,
    					'wrapper' => array(
    						'width' => '',
    						'class' => '',
    						'id' => '',
    					),
    					'default_value' => '',
    					'placeholder' => '',
    					'prepend' => '',
    					'append' => '',
    					'maxlength' => '',
    				),
    				array(
    					'key' => 'field_5dee11297baa7',
    					'label' => 'PDF File',
    					'name' => 'pdf_file',
    					'type' => 'file',
    					'instructions' => '',
    					'required' => 0,
    					'conditional_logic' => 0,
    					'wrapper' => array(
    						'width' => '',
    						'class' => '',
    						'id' => '',
    					),
    					'return_format' => 'url',
    					'library' => 'all',
    					'min_size' => '',
    					'max_size' => '',
    					'mime_types' => '',
    				),
    			),
    		),
    	),
    	'location' => array(
    		array(
    			array(
    				'param' => 'post_type',
    				'operator' => '==',
    				'value' => 'product',
    			),
    		),
    	),
    	'menu_order' => 0,
    	'position' => 'normal',
    	'style' => 'default',
    	'label_placement' => 'top',
    	'instruction_placement' => 'label',
    	'hide_on_screen' => '',
    	'active' => true,
    	'description' => '',
    ));
    
    endif;
    

    My PHP looks like this, but cannot get it to display anything…please help!

    add_filter( 'woocommerce_product_tabs', 'woo_new_product_tab' );
    function woo_new_product_tab( $tabs ) {
    // Adds the new tab
    	global $post;
    	if(get_field('pdf_brochure',$post->ID)) {
    	    $tabs['pdf_brochure_tab'] = array(
    	        'title'     => __( 'PDF Brochure', 'woocommerce' ),
    	        'priority'  => 50,
    	        'callback'  => 'woo_pdf_brochure_tab_content'
    	    );
    		}
    		if(get_field('demo_video',$post->ID)) {
    		$tabs['demo_video_tab'] = array(
    			'title'     => __( 'Demo Video', 'woocommerce' ),
    			'priority'  => 60,
    			'callback'  => 'woo_demo_video_tab_content'
    		);
    	}
    		if(get_field('parts_pdf',$post->ID)) {
    	    $tabs['parts_pdf_tab'] = array(
    	        'title'     => __( 'Parts', 'woocommerce' ),
    	        'priority'  => 50,
    	        'callback'  => 'woo_parts_pdf_tab_content'
    	    );
    		}
    
    		return $tabs;
    }
    
    function woo_parts_pdf_tab_content() {
    	global $post;
    	if(get_field('parts_pdf',$post->ID)) { ?>
    		<a href="<?php the_field('parts_pdf',$post->ID); ?>" target="_blank" class="pdf_brochure">Download Parts PDF</a>
    	<?php }
    }
    
    function woo_pdf_brochure_tab_content() {
    	global $post;
    	if(get_field('pdf_brochure',$post->ID)) { ?>
    		<a href="<?php the_field('pdf_brochure',$post->ID); ?>" target="_blank" class="pdf_brochure">Download Brochure</a>
    	<?php }
    }
    
    function woo_demo_video_tab_content() {
    	global $post;
    	if(get_field('demo_video',$post->ID)) {
    		the_field('demo_video');
    	}
    }
Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.