Replies: 0
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>';
}
}
}