Support

Account

Home Forums Add-ons Repeater Field Determine if a Sub Field with a specific title is present Reply To: Determine if a Sub Field with a specific title is present

  • Hi @brianwaxingmedia-com

    I wonder if you need to use the woo product TAB callback.

    So something like:

    <?php
    ########################
    # Add Custom Product Page TAB
    ########################
    add_filter( 'woocommerce_product_tabs', 'acf_woo_new_product_tab' );
    function acf_woo_new_product_tab( $tabs ) {
    	
    	global $product;
    	$product_id = $product->get_id();	
    	if( have_rows('details_repeater',$product_id ) ):
    		while( have_rows('details_repeater',$product_id ) ) : the_row();
    			if (get_sub_field('title') == 'Characteristics') :
    			// Adds the new tab
    			$tabs['product_details_tab'] = array(
    				'title' 	=> __( 'Characteristics', 'woocommerce' ),
    				'priority' 	=> 10,
    				'callback' 	=> 'acf_product_details_tab_content'
    			);	
    			endif;
    		endwhile;
    	endif;
    	
    	return $tabs;
    
    }
    
    function acf_product_details_tab_content() {
    
    	global $product;
    	$product_id = $product->get_id();
    	
    	// Check rows exists.
    	if( have_rows('details_repeater',$product_id ) ):
    		echo '<h2>Characteristics</h2>';
    		// Loop through rows.
    		while( have_rows('details_repeater',$product_id ) ) : the_row();
    
    			// Load sub field value.
    			$content = get_sub_field('content');
    			echo $content;
    
    		// End loop.
    		endwhile;
    
    	// No value.
    	else :
    		// Do something...
    	endif;	
    	
    }

    Code is untested but hopefully, you can see what’s happening.