Outputting Attributes on a single product page
-
Hi,
We are trying to output attributes in their own tab on the single product page.
We have success in outputting, but it outputs “Sizes” & “Ingredients” all in one go. What we’re trying to do, is output “Ingredients” only (“Ingredients” is our attribute):
The code currently is:function woo_new_product_tab_content() { // The new tab content echo '<h2>List of Ingredients in this product</h2>'; echo '<p>list of ingredients here...</p>'; global $product; $ingredients = $product->get_attributes(); $args = array( 'category' => array( 'category_slug' ) // or 'term_taxonomy_id' => 4 i.e. category ID ); foreach( $ingredients as $attr_name => $attr ){ foreach( $attr->get_terms() as $term ){ echo '<li>'. $term->name .'</li>'; //ALSO ATTEMPTED // echo '<li>'. array_shift( wc_get_product_terms( $product->id, 'pa_ingredients', array( 'fields' => 'names' ) ) ) .'</li>'; } } }
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
- The topic ‘Outputting Attributes on a single product page’ is closed to new replies.