Select the variations products meta and then paste this code into the custom function field for anyone who has the same issue:
// WoodMart variation gallery
function gallery_ids_in_string($post_id, $att_id, $filepath, $is_keep_existing_images = ”){
// The custom field used by gallery.
$key = ‘wd_additional_variation_images_data’;
// The separator to use between each ID.
$separator = “,”;
// Retrieve the current values in the gallery field.
$gallery = get_post_meta($post_id, $key, true);
// Ensure gallery is valid.
if (is_string($gallery) || is_empty($gallery) || ($gallery == false)) {
// Split value into array.
$gallery = explode($separator, $gallery);
// Add image if it’s not in the gallery.
if (!in_array($att_id, $gallery)) {
// Ensure array doesn’t start with empty value.
if ($gallery[0] == ”) unset($gallery[0]);
// Add image ID to array.
$gallery[] = $att_id;
// Save updated gallery field.
update_post_meta($post_id, $key, implode($separator, $gallery));
}
}
}
add_action(‘pmxi_gallery_image’, ‘gallery_ids_in_string’, 10, 4);
// Remove first image from gallery
function import_remove_featured_image_from_gallery($post_id, $xml_node) {
$thumbnail = get_post_meta($post_id, “_thumbnail_id”, true);
$gallery = get_post_meta($post_id, “wd_additional_variation_images_data”, true);
$gallery_array = explode(“,”, $gallery);
$check_thumbnail = array_search($thumbnail,$gallery_array);
if( $check_thumbnail !== false ) {
unset($gallery_array[$check_thumbnail]);
}
$gallery = implode(“,”, $gallery_array);
update_post_meta($post_id, “wd_additional_variation_images_data”, $gallery);
}
add_action(‘pmxi_saved_post’, ‘import_remove_featured_image_from_gallery’, 10, 2);