Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save simonlk/3967569 to your computer and use it in GitHub Desktop.
Save simonlk/3967569 to your computer and use it in GitHub Desktop.
Output Woocommerce product variations as a table so they look like a single product
<?php
// Output variations as a list so they look like a single product
// Works in theme/woocommerce/single-product/add-to-car/variable.php
?>
<table class="table table-striped table-hover">
<thead>
<tr>
<th>Ref #</th>
<?php foreach ( $attributes as $name => $options) :?>
<th><?php echo $woocommerce->attribute_label($name); ?></th>
<?php endforeach;?>
</tr>
</thead>
<tbody>
<?php foreach ($available_variations as $prod_variation) : ?>
<tr>
<td><?php echo $prod_variation['sku'] ;?></td>
<?php foreach ($prod_variation['attributes'] as $prod_attributes) : ?>
<td><?php echo $prod_attributes ;?></td>
<?php endforeach;?>
</tr>
<?php endforeach;?>
</tbody>
</table>
@Rajbir4all
Copy link

hello how can we get sales or regular price in the table with that.

REF # SIZE QUANTITY PRICE ADD TO CART

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment