Skip Navigation

[Resuelto] Woocommerce gallery in CRED

This support ticket is created hace 4 años, 2 meses. 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.

No supporters are available to work today on Toolset forum. Feel free to create tickets and we will handle it as soon as we are online. Thank you for your understanding.

Sun Mon Tue Wed Thu Fri Sat
- 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9: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/Karachi (GMT+05:00)

This topic contains 4 respuestas, has 2 mensajes.

Last updated by PZ hace 4 años, 2 meses.

Assisted by: Waqar.

Autor
Mensajes
#1484745

PZ

Hello,

I followed the solution form this topic (https://toolset.com/forums/topic/cred-repeating-image-fields-gallery-woo-and-non-woo/) to set woo gallery but it doesn't work for me.

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..

What am I missing? Please, help.

#1486697

Waqar
Supporter

Languages: Inglés (English )

Timezone: Asia/Karachi (GMT+05:00)

Hi,

Thank you for contacting us and I'd be happy to assist.

To troubleshoot why the same code snippet is not working on your website, I'll need its clone/snapshot.

Can you please share it, as explained in this guide?
https://toolset.com/faq/provide-supporters-copy-site/

Note: I've set your next reply as private.

regards,
Waqar

#1486705
#1489319

PZ

Hello, is there any progress?
Thanks.

#1489673

Waqar
Supporter

Languages: Inglés (English )

Timezone: Asia/Karachi (GMT+05:00)

Hi,

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 )

For the code snippet from Christian to work ( ref: https://toolset.com/forums/topic/cred-repeating-image-fields-gallery-woo-and-non-woo/#post-553621 ), the media library option needs to be checked.

Here is the slightly updated code snippet, which will work whether that option is turned on or not:


add_action('cred_save_data', 'cred_product_gallery_action',10,2);
function cred_product_gallery_action($post_id, $form_data)
{
	global $wpdb;
	// if a specific form
	if ($form_data['id']==39)
	{
		if (isset($_POST['wpcf-photo-gallery-alt']))
		{
			$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[0];
			}
			update_post_meta($post_id, '_product_image_gallery', implode($list_ids,','));
			delete_post_meta($post_id, 'wpcf-photo-gallery-alt');
		}
	}
}

I hope this helps and please let me know how it goes.

regards,
Waqar

#1489723

PZ

Thank you so much, it works great now.
I had to disable media library button because I got some other issues with the featured image but I'll create a new ticket if I can't sort it out by myself.

Thanks again and all the best,
pz

This ticket is now closed. If you're a WPML client and need related help, please open a new support ticket.