Support » Plugins and Hacks » Woocommerce – trouble displaying attribute values

  • I’m using Woocommerce for product display on a website I’m working on. When I’m fetching my custom attribute values I get what seems to be random empty strings between the values. Watch an example here:

    http://tec.macework.se/produkt/premium-short-sleeve-jersey-white/

    Here’s my code for fetching the values:

    <?php
    								$atts = get_the_terms( $product->id, 'pa_attribute-1');
    
    								      foreach ( $atts as $att ) { ?>
    								      <li>   <?php echo $att->name; ?> </li>
    
    									  <?php } wp_reset_query();
    
    					?>
    
    					<?php
    								$atts = get_the_terms( $product->id, 'pa_attribute-2');
    
    								      foreach ( $atts as $att ) { ?>
    								      <li>   <?php echo $att->name; ?> </li> 
    
    									 <?php }  wp_reset_query();
    
    					?>
    
    					<?php
    								$atts = get_the_terms( $product->id, 'pa_attribute-3');
    
    								      foreach ( $atts as $att ) { ?>
    
    								      <li>   <?php echo $att->name; ?> </li> 
    
    									 <?php } wp_reset_query();
    
    					?>
    
    					<?php
    								$atts = get_the_terms( $product->id, 'pa_attribute-4');
    
    								      foreach ( $atts as $att ) { ?>
    								      <li>   <?php echo $att->name; ?> </li> 
    
    									 <?php } wp_reset_query();
    
    					?>

    What’s up with the empty strings?

Viewing 3 replies - 1 through 3 (of 3 total)
  • Sorry for the ugly code spaces. Here:

    <?php
      $atts = get_the_terms( $product->id, 'pa_attribute-1');
    
    	foreach ( $atts as $att ) { ?>
    	 <li>   <?php echo $att->name; ?> </li>
    
    <?php } wp_reset_query(); ?>
    
    <?php $atts = get_the_terms( $product->id, 'pa_attribute-2');
    
    foreach ( $atts as $att ) { ?>
    
    <li>   <?php echo $att->name; ?> </li> 
    
     <?php }  wp_reset_query(); ?>
    
    <?php
    $atts = get_the_terms( $product->id, 'pa_attribute-3');
    
    foreach ( $atts as $att ) { ?>
    
    <li>   <?php echo $att->name; ?> </li> 
    
    <?php } wp_reset_query(); ?>
    
    <?php $atts = get_the_terms( $product->id, 'pa_attribute-4');
    
     foreach ( $atts as $att ) { ?>
    <li>   <?php echo $att->name; ?> </li> 
    
     <?php } wp_reset_query(); ?>
    esmi

    (@esmi)

    Forum Moderator

    Will do

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Woocommerce – trouble displaying attribute values’ is closed to new replies.