So I've been struggling to find any information on this and can't see any obvious way of doing it. I want to have a table in the product description listing certain attributes that I have set.
So for example in the description, I would have Title A followed by some text and a table with attributes 1, 2, and 3 then under Title B some text and attributes 4, 5, and 6.
I figured the easy way to do this would be to create a shortcode so I have tried and clearly missed something vital as it is not showing anything at all when I use it.
add_action( 'woocommerce_single_product_summary', 'show_attribute_group_a', 45 );
add_shortcode( 'show_attributes_a', 'show_attribute_group_a' );
function show_attribute_group_a() {
global $product;
$attribute1 = $product->get_attribute('attribute1');
$attribute2 = $product->get_attribute('attribute2');
?>
<table class="">
<tr class="">
<th class="">Attribute 1</th>
<td class=""><?php echo $attribute1; ?></td>
</tr>
<tr class="">
<th class="">Attribute 2</th>
<td class=""><?php echo $attribute2; ?></td>
</tr>
</table>
<?php
}
So where I have tried to pull the attributes I have used the slug of the attribute is that correct? But still, I would expect to see an empty table even if that part was wrong. There's obviously something fundamentally wrong and I can't see what.