Home › Forums › Add-ons › Repeater Field › Repeater field images to woocommerce gallery › Reply To: Repeater field images to woocommerce gallery
so it appears that woocommerce may be storing a comma separated list of id values? Now that I see the difference in the XML.
You could try
// priority of 20 so it runs after ACF
add_action('acf/save_post', 'my_acf_save_post', 20);
function my_acf_save_post($post_id) {
$repeater = 'other_images';
$subfield = 'image';
// using get_post_meta because that way
// we're sure to get the image ID
$count = intval(get_post_meta($post_id, $repeater, true));
$images = array();
for ($i=0; $i<$count; $i++) {
$field = $repeater.'_'.$i.'_'.$subfield;
$images[] = intval(get_post_meta($post_id, $field, true));
}
if (count($images)) {
// convert to comma separated list
$images = implode(',' $images);
} else {
$images = '';
}
update_post_meta($post_id, '_product_image_gallery', $images);
}
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.