Support » Plugin: WooCommerce » Show variations in a list on product page

  • Resolved jwiere03

    (@jwiere03)


    I’m using WooCommerce in a catalog mode. I have unhooked or edited theme files to change my layout quite a bit, but all of the products are variable products and I would like to list the variations. I don’t want a dropdown, I just want to list the variations in text on the product page.

    I have mocked up what I am looking for here https://johnscs.tinytake.com/sf/MjcxODg3NF84MTUzMjEx (not the real site, just a demo site I work on) ideally I can find a bit of code that I can add to my product template?

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Support ryanr14

    (@ryanr14)

    Hi @jwiere03,

    I’m sure there are plugins/extensions out there that may do what you want. For example is something like this helpful?

    https://barn2.co.uk/woocommerce-variations-table-plugin/

    I don’t want to add extra plugins. I was able to use get_available_variations(); to get what I needed. A simplified version of what I did is below, it was placed in the content-single-product.php file

    <?php 
    			$product = wc_get_product();
    			if ( $product->is_type( 'variable' ) ) {
    			$variations = $product->get_available_variations();
    foreach ($variations as $key => $value){
    	$scs_wc_size = $value['attributes']['attribute_pa_size'];
    	
    	echo  $scs_wc_size. ' ' . $value['price_html'].'<br/>';
    }
    			}
     ?>

    I was only showing the price and name of each variation, but there are is a lot of data that you could use from this. I also did some extra html formatting and used str_replace and ucwords functions to format my text.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Show variations in a list on product page’ is closed to new replies.