Tuesday, 30 March 2021

Handle WooCommerce selected variation custom field conditional display

I have this code where I need to insert a value based on a condition in: **///////// HERE THE MY CODE /////////**

Here I have overridden single-product/add-to-cart/variation.php Woocommerce template file via my active theme:

<script type="text/template" id="tmpl-variation-template">
<div class="woocommerce-variation-description">
}
</div>
 
<div class="woocommerce-variation-price">
}
</div>
 
<div class="woocommerce-variation-custom_field">
}
///////// HERE MY CODE /////////
</div>
 
<div class="woocommerce-variation-availability">
}
</div>
</script>

The condition should check the value of the variable `}` and if this data is greater than 10 then the code should print "Yes". 

**Something like**: 

    if( $data.variation.custom_field > 10 ){ 
        echo "yes";
    }

But it's not working. I guess, this should be done using Javascript instead of php but I don't know how grab the variable value.



from Handle WooCommerce selected variation custom field conditional display

No comments:

Post a Comment