Skip Navigation

[Resolved] add or upload product gallery images using Toolset CRED form

This thread is resolved. Here is a description of the problem and solution.

Problem:
Upload multiple image form Toolset CRED forms and assign it to product gallery images

Solution:
To add product gallery images you need to use Toolset form's hook "cred_save_data".

You can find the proposed solution in this case with the following reply:
https://toolset.com/forums/topic/multi-image-form-post/page/2/#post-1151131

Relevant Documentation:
https://toolset.com/documentation/user-guides/creating-woocommerce-products-using-cred-forms/

0% of people find this useful.

This support ticket is created 6 years ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
- 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Kolkata (GMT+05:30)

This topic contains 17 replies, has 3 voices.

Last updated by nicolasF-3 6 years ago.

Assisted by: Minesh.

Author
Posts
#1150507

Hello,
i would like to add multi image to my form post and a relationship field

Best regards
Mohammed

#1150550

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Hello. Thank you for contacting the Toolset support.

Well - I need more information regarding your issue. do you mean repeating field group or just repeating field?

When you use "Auto-Generate form" you do not get the required fields or the fields you are aiming to add is additional fields?
=> https://toolset.com/documentation/user-guides/styling-cred-forms/#auto-generate-form-markup

#1150561

Hi Minesh,

Thank you for your reply

here is my form,
hidden link

I have more problem:
I can not convert taxonomy into list select and I can not add the fields list of the designer in relationsip with the products

Best regards
Mohammed

#1150564

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Well - lets check the things step by step.

I still do not understand the issue for multiple image - could you please share more details on that - what issue you have with multiple image?

#1150567

after the validation the images do not appear in the detail of the products, the only one that is displayed is the image "_featured_image"

#1150574

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Do you mean that you have custom validations added to your form? If yes - could you please tell me what are those?

And once you uploaded a few images to your form field "Additional Picture" and you validate those custom validation, once the form is validated - it's not displaying the uploaded images?

#1150598
test.jpg

Hello,
here you will find a print screen.

product gallery is empty after validation
Best regards
Mohammed

#1150610

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Well - it seems the screenshot you shared is from backend.

Could you please send me exact step information I need to follow that will help me to reproduce the issue as well as access details.

*** Please make a FULL BACKUP of your database and website.***
I would also eventually need to request temporary access (WP-Admin and FTP) to your site. Preferably to a test site where the problem has been replicated if possible in order to be of better help and check if some configurations might need to be changed.

I would additionally need your permission to de- and re-activate Plugins and the Theme, and to change configurations on the site. This is also a reason the backup is really important. If you agree to this, please use the form fields I have enabled below to provide temporary access details (wp-admin and FTP).

I have set the next reply to private which means only you and I have access to it.

#1150631

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Could you please send me exact step information I need to follow that will help me to reproduce the issue as well as access details.

#1150635

Hi,
When I save the form after validation, the images I added cannot be found in the Gallery of the product
and I cannot display the fields relationship in the form.

Best regards
Mohammed

#1150641

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Well - my question is what data I should use for which form fields to display to invalidate the form? Do you have any specific custom validations added? as form is validated using javascript - have you added any custom validations using Forms hook cred_form_validate?

#1150662

Hi Sir,

The only thing I would like is to add multiple pictures in the form.
These pictures should be linked to the product. This is not the case now.

Second thing is that I would like the relationship "Product Designer" to appear in the form.
So people can choose to see the products from only one specific designer.

Kind regards

#1150673

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Could you please kindly give me information what I asked and that will help me to understand your issue as well as to guide you in right direction. Could you please answer following questions:

my question is:
- what data I should use for which form fields to display to invalidate the form?
-Do you have any specific custom validations added? as form is validated using javascript
- have you added any custom validations using Forms hook cred_form_validate?

The only thing I would like is to add multiple pictures in the form.
These pictures should be linked to the product. This is not the case now.
==> Is it the case that even though you uploaded the images using "Additional Picture" but its not showing in the backend after you submit the product?

Additionally, the access details you shared in not working. Please share working access details.

I have set the next reply to private which means only you and I have access to it.

#1151131

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Well - Could you please check the following documentation page which describes what you can and cannot do when creating and editing WooCommerce products using Toolset (CRED) forms:
=> https://toolset.com/documentation/user-guides/creating-woocommerce-products-using-cred-forms/

There is a detailed table given where its clearly informed tha what fields you can use with Toolset forms to create products:
and you will see that for product gallery images they can only be used with custom coding and not with Tooslet forms directly.
=> https://toolset.com/documentation/user-guides/creating-woocommerce-products-using-cred-forms/#which-product-fields-you-can-use-in-toolset-forms

I've added following code to your current theme's functions.php file so whatever additional images you upload it will be linked to product gallery field:

/**
 * Create product image gallery during Forms submission
 *
 */
add_action('cred_save_data', 'func_add_product_gallery_image',10,2);
function func_add_product_gallery_image($post_id, $form_data)
{
    global $wpdb;
    // if a specific form
    if ($form_data['id']==14407)
    {
        if (isset($_POST['wpcf-additional_images']))
        {
           $list_ids = array();
            foreach($_POST['wpcf-additional_images'] as $url) {
              $item_id = $wpdb->get_col($wpdb->prepare("SELECT ID FROM $wpdb->posts WHERE guid='%s';", $url ));
              $list_ids[] = $item_id[0];
            }
            update_post_meta($post_id, '_product_image_gallery', implode($list_ids,','));
           // delete_post_meta($post_id, 'wpcf-product-gallery-image-cred');
        }
    }
}

Now, once you upload the additional images - the same images will be assigned to product gallery image as well.

Regarding your any additional questions, please kindly open a new ticket as it will help us to write the correct ticket resolution summery as well as help other users searching on the forum the same issue.

#1151136

Thanks for your help.
I can not do it, it is to give the possibility to the visitor to link a designer to the product in the form.
I searched on the internet but I did not find anything