I'm trying to hide the variation description on product pages if the variation's stock is >=1. Following this I have made this code which is not working:
add_action ('woocommerce_after_single_variation', 'hide_descriptions', 10);
function hide_descriptions() {
$stock_qty = $product->get_stock_quantity();
if ($stock_qty>=1)
?>
<div class="woocommerce-variation-description" style="display: none!important;"></div>
<?php
}
I've also tried with the action hook 'woocommerce_single_variation'
since the class="woocommerce-variation-description"
is located inside the class="woocommerce-variation single_variation"
- and the latter class is called by the function woocommerce_single_variation()
.
But how do you access a nested class with a hook that targets its parent?