I would like to display the default product attributes form value and it's regular price in my front end template file.
The var_dump
below shows options in an array. I Need to get the [default_attributes]
values.
<?php
global $product;
echo var_dump( $product );
// Need to get the [default_attributes] values
?>
To get the default attributes for a variable product you can use
WC_Product
methodget_default_attributes()
this way:Now to find out which is the corresponding product variation for this "defaults" attributes, is a little more complicated:
This is tested and works.