Hello,
I’m not the author but I found this problem as well. I managed with this solution:
$specifications = dw_get_table_result($pid);
where $pid
is my product id.
$first_group = array_column($specifications[0]['attributes'], 'value', 'attr_name');
$second_group = array_column($specifications[1]['attributes'], 'value', 'attr_name');
$third_group = array_column($specifications[2]['attributes'], 'value', 'attr_name');
$third_group_unit = array_column($specifications[2]['attributes'], 'attr_desc', 'attr_name');
etc… my first and second groups are true/false and the third is a input type text where the description is the unit.
And then I made a foreach loop each like if it’s true/false if it’s text then just simple echo it etc.:
<?php foreach ($first_group as $group_text => $group_value): ?>
<?php if ($group_value == 'yes'): ?>
<li class="product-allergic-li"><?php echo $group_text; ?></li>
<?php endforeach; ?>
Limit 2 means you have to use <?php for ?> on the product_id’s array.
If you have any question feel free to ask.
Here’s my code based on your snippet:
foreach(dw_get_table_result($product->get_id()) as $group) {
echo '<h5>' . $group[group_name] . '</h5>';
foreach($group[attributes] as $attr) {
echo '<p><strong>' . $attr[attr_name] . '</strong>';
echo ': ' . $attr[value] . '</p>';
}
}
Here is what it returns:
Group 1
Attribute 1: Value
Attribute 2: Value
Attribute 3: Value
Group 2
Attribute 1: Value
Attribute 2: Value
Attribute 3: Value
Thank you @cziberez for your help on the initial code,
Martin
If you’re using the shortcode outside a loop, adding the post_id
attribute will help :
<?php echo do_shortcode('[specs-table post_id=123]'); ?>
where 123
is your product id.
Hey, I didn’t know the shortcode supports a post_id
attribute, why is it not mentioned in the plugin’s description or FAQ section????!
Thank you @pelentak
Martin
Plugin Author
Amin
(@dornaweb)
@iconstudiosny I’m sorry for the incomplete FAQ, but yes, the shortcode does support a post_id
value.