I've created a variable product using woocommerce plugin. In the variable product I've created a custom attribute "License Duration" with values "3 Months | 6 Months | 1 Year | Life Time".
Now I want to display this attribute on a custom single product template.
I've tried following solutions
1.
$licenseDurations = get_the_terms( $post->ID, 'attribute_license-duration' );
This shows following on var_dump($licenseDurations);
`
object(WP_Error)[558]
public 'errors' =>
array (size=1)
'invalid_taxonomy' =>
array (size=1)
0 => string 'Invalid taxonomy' (length=16)
public 'error_data' =>
array (size=0)
empty`
and
2.
global $product;
$licenseDuration = $product->get_attribute( 'License Duration' ); // Here I also tried attribute slug `attribute_license-duration` instead of `License Duration` but no use
Ref: https://stackoverflow.com/a/13454788/2758870
and
3.
global $product;
$licenseDurations = get_the_terms( $product->id, 'License Duration');
foreach ( $licenseDurations as $licenseDuration )
{
echo $licenseDuration->name;
}
in both of above cases I got nothing because $product;
is returning null
on var_dump($product)
4. I've also tried this code http://isabelcastillo.com/woocommerce-product-attributes-functions
by directly calling isa_woo_get_one_pa()
where I want to show values. but with no luck.
Anyone here please help...