Pre-populate Gravity Forms Field with Custom Post Type

In your foreach statement you are both trying to get and assign properties on a non-object, in essence, the $field variable is actually not an object, but rather an array. I don’t know why the example code on the Gravity Forms website is using object notation, perhaps the underlying API has changed.

Anyway here is what you need:

add_filter( 'gform_pre_render_3', 'list_diesel_heater' );
add_filter( 'gform_pre_validation_3', 'list_diesel_heater' );
add_filter( 'gform_pre_submission_filter_3', 'list_diesel_heater' );
add_filter( 'gform_admin_pre_render_3', 'list_diesel_heater' );
function list_diesel_heater( $form ) {

    foreach ( $form['fields'] as &$field ) {

        if ( $field['type'] != 'checkbox' ) {
            continue;
        }

        $posts = get_posts( 'numberposts=-1&post_type=product&product_cat=clothing' );

        $choices = array();

        foreach ( $posts as $post ) {
            $thumb = wp_get_attachment_image_src( get_post_thumbnail_id($post->ID), 'thumbnail' );
            $choices[] = array( 'text' => '<img src="' . $thumb['0'] . '"><p>'. $post->post_title .'</p>', 'value' => $post->post_title );
        }

        $field['placeholder'] = 'Select a Post';
        $field['choices'] = $choices;

    }

    return $form;

}

I have changed the product_cat above and removed the second statement in the first conditional so as to test this code on my WooCommerce development envioronment using the WooCommerce dummy data XML file, therefore you need to change things back to your specifications.

Here is an example of the output:

enter image description here

You will need to style the output yourself accordingly