• Resolved carver1g

    (@carver1g)


    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://www.ads-software.com/plugins/wc-fields-factory/

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author Saravana Kumar K

    (@mycholan)

    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

    (@carver1g)

    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.