Override variation.php template
-
Hi there!
I need to override the woocommerce/templates/single-product/add-to-cart/variation.php template.
I already copied it to my theme folder and it is working fine.
Problem is that I need to insert a Conditional code in this new template.
The condition should check the value of the variabledata.variation.priceand if it value is greater than 10 then the code should print “Yes”.Something like this: (I tried this but not working):
if($data.variation.price > 10){ echo “yes”;}
I guess, this should be done using js instead of php but I don’t know how grab the variable value.
This is the code for my template page.
I need to insert the conditional just where it writes ///////// HERE MY CODE /////////<script type="text/template" id="tmpl-variation-template"> <div class="woocommerce-variation-description"> <code>data.variation.variation_description</code> </div> <div class="woocommerce-variation-price"> <code>data.variation.price_html</code> ///////// HERE MY CODE ///////// </div> <div class="woocommerce-variation-availability"> <code>data.variation.availability_html</code> </div> </script>
The topic ‘Override variation.php template’ is closed to new replies.