Support

Account

Home Forums Front-end Issues Display product repeater field values in custom tab

Helping

Display product repeater field values in custom tab

  • Hi!

    Im having problems with showing product’s ACF repeater values in theme.
    I have 1 product cat (Wheels) that has repeater field wh_info with subfields name wh_name, wh_model, wh_year, wh_specs.

    I added this to functions.php to display custom tab for only Wheels

    add_filter( 'woocommerce_product_tabs', 'woo_custom_product_tabs' );
    
        function woo_custom_product_tabs( $tabs ) {
    
          global $post;
         if ( is_product() && has_term( 'Wheels', 'product_cat' )) 
         { 
          $tabs['custom_specification'] = array( 'title' => __( 'Specification', 'woocommerce' ), 'priority' => 50, 'callback' => 'woo_custom_specification_content' );
          }
          return $tabs;
        }
    
    function woo_custom_specification_content() {
    
    	// The new tab content
    	echo '<h2>New Product Tab</h2>';
    	echo 'Here\'s your new product tab.
    ';
    	
    }

    What code should I add to display product’s repeater values in the tab? Each snippet I have tried sums up with HTTP 500.

  • The code you are using looks good.. in terms of what I saw in the Woo docs.

    Now… your callback function… that’s where you are having troubles displaying ACF Repeater field data?

    Have you tried passing the post ID to the Repeater, which would mean adding:

    global $post;

    then…

    get_field( 'wh_info', $post->ID );

Viewing 2 posts - 1 through 2 (of 2 total)

The topic ‘Display product repeater field values in custom tab’ is closed to new replies.