Title: Programmatically change variation
Last modified: October 7, 2021

---

# Programmatically change variation

 *  Resolved [nurulpowa](https://wordpress.org/support/users/nurulpowa/)
 * (@nurulpowa)
 * [4 years, 8 months ago](https://wordpress.org/support/topic/programmatically-change-variation/)
 * Ciao ragazzi! Prima di tutto complimenti, i vostri prodotti sono fenomenali. (
   Ora continuo in inglese in caso dovesse essere utile ad altri).
 * I would really need a help from you on a feature I’m working on. So basically,
   I have an addon of type labels and in the description I have placed a shortcode(
   for which I had to edit a line on one of your plugin files). The shortcode is
   needed for the customer to select their nearest store by entering their postcode.
 * Image here: [https://imgur.com/a/Xv8nQzD](https://imgur.com/a/Xv8nQzD)
 * Now, what I am trying to do is to change the variation value to the name of the
   store selected. Because once the user add the product to the cart, the variation
   is the title of the field (in this case ‘Test’) and it stays like that on the
   checkout page and emails.
 * Image here: [https://imgur.com/a/xdSzZyB](https://imgur.com/a/xdSzZyB)
 * It would be really helpful if you could give me a hint on which file should I
   insert my custom code in order to change the variation value programmatically.
 * Thanks.

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

 *  [crodriguez1991](https://wordpress.org/support/users/crodriguez1991/)
 * (@crodriguez1991)
 * [4 years, 8 months ago](https://wordpress.org/support/topic/programmatically-change-variation/#post-14947526)
 * Hello there,
 * We hope you’re doing well 😀
 * In this case you should save the value the customer use in the selector in order
   to retrieve the information and replace the value.
 * The section where our plugin add the label and value in the cart is in
 * `/includes/class-yith-wapo-cart.php` on get_item_data() method.
 * Maybe it’s possible to leave a filter on the cart data in order you can change
   the value
 *     ```
       $cart_data[] = array(
       		 'name'    => $key,
       		'display' => $value,
       	     );
       ```
   
 * Do you have the information of the user selection at this level? we think in 
   this way you can get your goal and change the display value
 * We hope it helps you.
 * Please, check it and let us know.
 *  Thread Starter [nurulpowa](https://wordpress.org/support/users/nurulpowa/)
 * (@nurulpowa)
 * [4 years, 8 months ago](https://wordpress.org/support/topic/programmatically-change-variation/#post-14953843)
 * Hi Carlos,
 * Thanks a lot for your help. I was able to achieve the goal by changing the display
   value with the value selected by the user.
 * In addition to that, even the **order_item_meta()** method needed some custom
   code in order to display the correct value in the thank you page, email and admin
   page.
 * Carlos thanks again for your guidance, it was the exact information I was looking
   for.
 *  Plugin Support [Andrea Grillo](https://wordpress.org/support/users/agengineering/)
 * (@agengineering)
 * [4 years, 8 months ago](https://wordpress.org/support/topic/programmatically-change-variation/#post-14972603)
 * Hi there,
 * seems a big of this version, we scheduled to release the version 2.2.5 today.
   
   This new version include a fix for this issue.
 * Please, make a test after update and let me know if this solve the problem.
 * Thanks.
    -  This reply was modified 4 years, 8 months ago by [Andrea Grillo](https://wordpress.org/support/users/agengineering/).

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

The topic ‘Programmatically change variation’ is closed to new replies.

 * ![](https://ps.w.org/yith-woocommerce-product-add-ons/assets/icon-128x128.gif?
   rev=3142291)
 * [YITH WooCommerce Product Add-Ons](https://wordpress.org/plugins/yith-woocommerce-product-add-ons/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/yith-woocommerce-product-add-ons/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/yith-woocommerce-product-add-ons/)
 * [Active Topics](https://wordpress.org/support/plugin/yith-woocommerce-product-add-ons/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/yith-woocommerce-product-add-ons/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/yith-woocommerce-product-add-ons/reviews/)

 * 3 replies
 * 3 participants
 * Last reply from: [Andrea Grillo](https://wordpress.org/support/users/agengineering/)
 * Last activity: [4 years, 8 months ago](https://wordpress.org/support/topic/programmatically-change-variation/#post-14972603)
 * Status: resolved