Title: Override variation.php template
Last modified: March 24, 2021

---

# Override variation.php template

 *  Resolved [chefnelone](https://wordpress.org/support/users/chefnelone/)
 * (@chefnelone)
 * [5 years, 2 months ago](https://wordpress.org/support/topic/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 variable `data.variation.price` and 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>
       ```
   

Viewing 5 replies - 1 through 5 (of 5 total)

 *  Plugin Support [Stuart Duff – a11n](https://wordpress.org/support/users/stuartduff/)
 * (@stuartduff)
 * Automattic Happiness Engineer
 * [5 years, 2 months ago](https://wordpress.org/support/topic/override-variation-php-template/#post-14228323)
 * Hi [@chefnelone](https://wordpress.org/support/users/chefnelone/),
 * This document below may help as it references how the wp.template is used to 
   create Underscore.js style template functions that, when executed, generates 
   parametrized HTML for rendering.
 * [https://codex.wordpress.org/Javascript_Reference/wp.template](https://codex.wordpress.org/Javascript_Reference/wp.template)
 * You can find the wp.template instances within WooCommerce in this search below.
 * [https://github.com/woocommerce/woocommerce/search?q=wp.template](https://github.com/woocommerce/woocommerce/search?q=wp.template)
 *  Thread Starter [chefnelone](https://wordpress.org/support/users/chefnelone/)
 * (@chefnelone)
 * [5 years, 2 months ago](https://wordpress.org/support/topic/override-variation-php-template/#post-14233073)
 * Hi,
 * I am afraid I don’t have the right knowledge to get this.
 * Is there a page with examples to figure this out. I just need to add a single“
   conditional” line of code.
 * Thanks!
 *  Plugin Support [Stuart Duff – a11n](https://wordpress.org/support/users/stuartduff/)
 * (@stuartduff)
 * Automattic Happiness Engineer
 * [5 years, 2 months ago](https://wordpress.org/support/topic/override-variation-php-template/#post-14243184)
 * Hey [@chefnelone](https://wordpress.org/support/users/chefnelone/),
 * There are some tutorials available on Google which may help you understand the
   wp.template functionality.
 * [https://www.google.com/search?q=using+wp.template+javascript](https://www.google.com/search?q=using+wp.template+javascript)
 * It may be that you’ll need to have a developer write some custom code for you
   that could achieve your desired results. If you would like to investigate that
   possibility further, you could reach out to some of the official WooCommerce 
   development partners like Codeable via this link below.
 * [https://woocommerce.com/customizations/](https://woocommerce.com/customizations/)
 *  [MayKato](https://wordpress.org/support/users/maykato/)
 * (@maykato)
 * [5 years, 2 months ago](https://wordpress.org/support/topic/override-variation-php-template/#post-14272891)
 * Hi [@chefnelone](https://wordpress.org/support/users/chefnelone/)
 * We’ve not heard back from you in a while, so I’m marking this thread as resolved.
   If you have further questions, please feel free to open a new topic.
 *  [Jose Lazo](https://wordpress.org/support/users/jose-lazo/)
 * (@jose-lazo)
 * [5 years ago](https://wordpress.org/support/topic/override-variation-php-template/#post-14463729)
 * Hi [@chefnelone](https://wordpress.org/support/users/chefnelone/)
 * To add conditional you have to use underscorejs syntax:
 *     ```
       <# if ( data.variation.price > 10 ) { #>
           <code>data.variation.price</code>
       <# } #>
       ```
   
 * Good luck

Viewing 5 replies - 1 through 5 (of 5 total)

The topic ‘Override variation.php template’ is closed to new replies.

 * ![](https://ps.w.org/woocommerce/assets/icon.svg?rev=3234504)
 * [WooCommerce](https://wordpress.org/plugins/woocommerce/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/woocommerce/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/woocommerce/)
 * [Active Topics](https://wordpress.org/support/plugin/woocommerce/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/woocommerce/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/woocommerce/reviews/)

 * 5 replies
 * 4 participants
 * Last reply from: [Jose Lazo](https://wordpress.org/support/users/jose-lazo/)
 * Last activity: [5 years ago](https://wordpress.org/support/topic/override-variation-php-template/#post-14463729)
 * Status: resolved