WooCommerce - display variations as single products using custom loop

Viewed 234

I have one variation product on my store with two options to choose. What I trying to do is to display all variations as a separate products to choose with custom loop in my PHP template file.

So far I can display variation name with my code:

<?php 
  $sub_values = get_the_terms( $product->id, 'pa_sub-select');
  foreach ( $sub_values as $sub_value ) {
?>
    <li>
        <span><?php echo $sub_value->name; ?></span>
        <span>Price for this package is: </span>
        <a href="#">Add to cart now</a>
    </li>
<?php } ?>

But how can I show also a variation price, and "add to cart" link? Or meybe it can be done with functions.php to modify default archive-product.php loop?

0 Answers
Related