Title: Problem with variable products
Last modified: August 31, 2016

---

# Problem with variable products

 *  Resolved [carver1g](https://wordpress.org/support/users/carver1g/)
 * (@carver1g)
 * [10 years ago](https://wordpress.org/support/topic/problem-with-variable-products-3/)
 * I can add simple products with no problem but varialble products are a different
   story. Adding attributes goes fine but when creating product variations the following
   notice is shown on the ‘Add new product’ page:
 * Notice: Undefined variable: post in C:\server\site\wordpress\wp-content\plugins\
   wc-fields-factory\classes\wcff-admin-form.php on line 173
 * Notice: Trying to get property of non-object in C:\server\site\wordpress\wp-content\
   plugins\wc-fields-factory\classes\wcff-admin-form.php on line 173
 * After saving product variations this notice appears:
 * Notice: Trying to get property of non-object in C:\server\site\wordpress\wp-content\
   plugins\wc-fields-factory\classes\wcff-admin-form.php on line 298
 * Notice: Trying to get property of non-object in C:\server\site\wordpress\wp-content\
   plugins\wc-fields-factory\classes\wcff-admin-form.php on line 298
 * I went ahead and added a variable product despite the notices and on the frontend
   the display is, what one might say, a bit messed up.
 * Am using – WordPress 4.5.2, woocommerce 2.5.5 and storefront 2.0.1.
 * I have several plugins installed but your plugin, without a doubt, is my favorite
   and works best for what I have to offer.
 * Any help will be greatly appreciated.
 * [https://wordpress.org/plugins/wc-fields-factory/](https://wordpress.org/plugins/wc-fields-factory/)

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

 *  Plugin Author [Saravana Kumar K](https://wordpress.org/support/users/mycholan/)
 * (@mycholan)
 * [10 years ago](https://wordpress.org/support/topic/problem-with-variable-products-3/#post-7407855)
 * Hi, thanks for raising this, I got the issues. the fix simple but I cannot release
   it now as I am working on some pending features. So I will tell you where to 
   edit, please update it by yourself.
 * Open `plugins/wc-fields-factory/classes/wcff-admin-form.php`
 * `function inject_wccaf_on_product_variable_section( $loop, $variation_data, $
   variation )` LN : 170
 * put `global $post;` at the beginning of that function.
 * `function save_wccaf_product_variable_fields( $variant_id, $i )` LN : 297
 * replace that whole function with the below
 *     ```
       function save_wccaf_product_variable_fields( $variant_id, $i ) {
       	global $post;
       	$parent_post_id = -1;
   
       	if( !$post ) {
       		$parent_post_id = wp_get_post_parent_id( $variant_id );
       	} else {
       		$parent_post_id = $post->ID;
       	}
   
       	$this->location = "woocommerce_product_after_variable_attributes";
       	$all_fields = apply_filters( 'wcff/load/all_fields', $parent_post_id, 'wccaf', $this->location );
       	if( count( $all_fields ) > 0 ) {
       		foreach ( $all_fields as $fields ) {
       			if( count( $fields ) > 0 ) {
       				foreach ( $fields as $key => $field ) {
       					if( isset( $_REQUEST[ $field["name"] ][$i] ) ) {
       						update_post_meta( $variant_id, "wccaf_". $field["name"], $_REQUEST[ $field["name"] ][$i] );
       					}
       				}
       			}
       		}
       	}
       }
       ```
   
 * I will release the fix with my next release.
 *  Thread Starter [carver1g](https://wordpress.org/support/users/carver1g/)
 * (@carver1g)
 * [10 years ago](https://wordpress.org/support/topic/problem-with-variable-products-3/#post-7407964)
 * Followed your instructions and as usual everything is working perfectly!
 * Much thanks

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

The topic ‘Problem with variable products’ is closed to new replies.

 * ![](https://ps.w.org/wc-fields-factory/assets/icon-128x128.jpg?rev=2738843)
 * [WC Fields Factory](https://wordpress.org/plugins/wc-fields-factory/)
 * [Support Threads](https://wordpress.org/support/plugin/wc-fields-factory/)
 * [Active Topics](https://wordpress.org/support/plugin/wc-fields-factory/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/wc-fields-factory/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/wc-fields-factory/reviews/)

 * 2 replies
 * 2 participants
 * Last reply from: [carver1g](https://wordpress.org/support/users/carver1g/)
 * Last activity: [10 years ago](https://wordpress.org/support/topic/problem-with-variable-products-3/#post-7407964)
 * Status: resolved