Tout est dit dans le titre.
Dans fonctions.php :
add_action( 'save_post', 'my_save_post', 10, 3 );
function my_save_post($post_id){
$post = get_post( $post_id );
if($post->post_type !== 'product'){
return;
}
$post = new WC_product( $post_id );
$attachment_ids = $post->get_gallery_image_ids();
$image_thumbnail = get_post_meta($post_id, '_thumbnail_id', TRUE);
if(empty($image_thumbnail) && !empty($attachment_ids)){
$image_thumbnail_id = $attachment_ids[0];
update_post_meta($post_id, '_thumbnail_id', $image_thumbnail_id, '');
}
}