First, I removed wpcf- prefix from the code.
If I add it in front of the field slug, the pictures don't even show in the gallery custom field in back-end editor (they are uploaded into the media library, though) and neither in woocomerce gallery.
Without the prefix the pictures show in the back-end in my gallery custom fields but not in woocommerce gallery.
I only changed form id and my custom field slug in the provided code..
Thank you for waiting, while I performed some troubleshooting.
I noticed that in your target form "Alternative places form" (ID: 39), the option "Use the WordPress Media Library manager for image, video, audio, or file fields" was not checked.
( screenshot: hidden link )
Here is the slightly updated code snippet, which will work whether that option is turned on or not:
function cred_product_gallery_action($post_id, $form_data)
// if a specific form
$list_ids = array();
$existing_values = get_post_meta( $post_id, 'wpcf-photo-gallery-alt', false );
foreach($existing_values as $url)
$item_id = $wpdb->get_col($wpdb->prepare("SELECT ID FROM $wpdb->posts WHERE guid='%s';", $url ));
$list_ids = $item_id;
update_post_meta($post_id, '_product_image_gallery', implode($list_ids,','));
I hope this helps and please let me know how it goes.