woocommerce show attribute description when selecting a variable
- by user2916995
I'm trying to figure out a way to display custom text based on the users selection of the variable product.
The attribute is 'pricing' and the tag is deposit - which I've added a text description to when adding the attribute. So I'm trying to make this text appear when the user selects 'deposit'
But the code I'm using in 'content-single-product.php' is displaying the text all the time no matter what variable is selected or not.
<?php $my_taxonomy = 'pa_pricing';
$terms = wp_get_post_terms( $post->ID, $my_taxonomy );
echo term_description($terms[0]->term_id, $my_taxonomy);
?>
I only want the text to be displayed after the user has selected pricing 'deposit' Can someone help me with this?