Title: update variations via php
Last modified: May 31, 2021

---

# update variations via php

 *  Resolved [jhwarp](https://wordpress.org/support/users/jhwarp/)
 * (@jhwarp)
 * [5 years ago](https://wordpress.org/support/topic/update-variations-via-php/)
 * This plugin looks perfect for my use case. I am abandoning some (premium) plugins
   that does not offer the functionality that this does. So thanks a lot.
 * I want to find out, is there a way that I can update min quantity for product
   variations via php? Something like update_post_meta perhaps? The reason why I
   want to do this, is because I have the data in another plugin, but want to transfer
   it over to yours without manually changing each variation. So I’m doing something
   like: `
 *     ```
       $args = array(
               'post_type'      => 'product',
               'posts_per_page' => -1,
           );
       		$loop = new WP_Query( $args );
   
            while ( $loop->have_posts() ) : $loop->the_post();
               global $product;	 
       	$min_value = get_post_meta(get_the_id(), 'old_plugin_meta_for_min', true );
   
       	if ($min_value) {
           //	update_post_meta( get_the_id(), 'berocket_min_quantity', $min_value );
   
       		}
            endwhile;
   
            wp_reset_query();
       ```
   
 * This works 100% fine for simple products, but is this possible with variations?

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

 *  Plugin Author [RazyRx](https://wordpress.org/support/users/razyrx/)
 * (@razyrx)
 * [5 years ago](https://wordpress.org/support/topic/update-variations-via-php/#post-14507018)
 * Hello,
 * In products plugin use post meta with names `min_quantity` and `max_quantity`.
   
   In product variations plugin use post meta with names `min_quantity_var` and `
   max_quantity_var`.
 * Regards,
    Oleg
 *  Thread Starter [jhwarp](https://wordpress.org/support/users/jhwarp/)
 * (@jhwarp)
 * [5 years ago](https://wordpress.org/support/topic/update-variations-via-php/#post-14507930)
 * Thanks for not only giving meta keys, but also where they are used. This helps
   out a lot!
 *  Plugin Author [RazyRx](https://wordpress.org/support/users/razyrx/)
 * (@razyrx)
 * [5 years ago](https://wordpress.org/support/topic/update-variations-via-php/#post-14510298)
 * Hello,
 * What do you mean with “where they are used”?
    Do you need php file name where
   it is used or place on page where you can change it?
 * Regards,
    Oleg
 *  Thread Starter [jhwarp](https://wordpress.org/support/users/jhwarp/)
 * (@jhwarp)
 * [5 years ago](https://wordpress.org/support/topic/update-variations-via-php/#post-14510323)
 * No no, you misunderstood, I wasn’t being clear enough 🙂
 * I was saying thank you for pointing out in which plugin they were used (in products
   plugin and in variations plugin). This helped me out a lot. Thank you

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

The topic ‘update variations via php’ is closed to new replies.

 * ![](https://ps.w.org/minmax-quantity-for-woocommerce/assets/icon-256x256.gif?
   rev=2770663)
 * [Min and Max Quantity for WooCommerce](https://wordpress.org/plugins/minmax-quantity-for-woocommerce/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/minmax-quantity-for-woocommerce/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/minmax-quantity-for-woocommerce/)
 * [Active Topics](https://wordpress.org/support/plugin/minmax-quantity-for-woocommerce/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/minmax-quantity-for-woocommerce/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/minmax-quantity-for-woocommerce/reviews/)

## Tags

 * [php](https://wordpress.org/support/topic-tag/php/)
 * [update](https://wordpress.org/support/topic-tag/update/)
 * [variations](https://wordpress.org/support/topic-tag/variations/)

 * 4 replies
 * 2 participants
 * Last reply from: [jhwarp](https://wordpress.org/support/users/jhwarp/)
 * Last activity: [5 years ago](https://wordpress.org/support/topic/update-variations-via-php/#post-14510323)
 * Status: resolved