Title: Product variations variable
Last modified: August 21, 2016

---

# Product variations variable

 *  [TimoVeld](https://wordpress.org/support/users/timoveld/)
 * (@timoveld)
 * [13 years ago](https://wordpress.org/support/topic/product-variations-variable/)
 * Hi all,
    I’d like to edit my product page in a way that is depending on the selected
   variation. Meaning: I want action-A to occur when option a is selected, when 
   option-B is selected as variation, I want action-B to happen.
 * So basically I just want to “catch” what variation is selected and use that information
   to make something happen on the product page.
 * Any suggestions?
 * [http://wordpress.org/extend/plugins/woocommerce/](http://wordpress.org/extend/plugins/woocommerce/)

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

 *  Thread Starter [TimoVeld](https://wordpress.org/support/users/timoveld/)
 * (@timoveld)
 * [13 years ago](https://wordpress.org/support/topic/product-variations-variable/#post-3757718)
 * I’m gessing I need something like
 *     ```
       <?php
       if ($selected_value == 'AttributeValue')
        {$phpVar = 1;}
       else
       {$phpVar = 5;}
       ?>
       ```
   
 * But I can’t seem to get it to work
 *  [IgniteWoo Team](https://wordpress.org/support/users/ignitewoo/)
 * (@ignitewoo)
 * [13 years ago](https://wordpress.org/support/topic/product-variations-variable/#post-3757727)
 * If you want to do that when the variation is selected ( e.g. not added to cart
   yet ) then you should use jQuery. Or do you want to do this after it’s added 
   to the cart?
 *  Thread Starter [TimoVeld](https://wordpress.org/support/users/timoveld/)
 * (@timoveld)
 * [13 years ago](https://wordpress.org/support/topic/product-variations-variable/#post-3757748)
 * No I want to do it before it is added to cart.
    So are you saying I’m in the 
   right direction with $selected value? Only I have to make the change with jQuery,
   not with php?
 *  Thread Starter [TimoVeld](https://wordpress.org/support/users/timoveld/)
 * (@timoveld)
 * [13 years ago](https://wordpress.org/support/topic/product-variations-variable/#post-3757753)
 * What I’m actually keen on finding, is how the prices are generated when selecting
   an attribute. If I could see how this functions works, I could just copy and 
   modify it’s code to my needs.

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

The topic ‘Product variations variable’ 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/)

 * 4 replies
 * 2 participants
 * Last reply from: [TimoVeld](https://wordpress.org/support/users/timoveld/)
 * Last activity: [13 years ago](https://wordpress.org/support/topic/product-variations-variable/#post-3757753)
 * Status: not resolved