fbpx
Want To Add Extra Images Per Product Variation For Free? Download Now

I want to delete variation image gallery when i delete products

 

I have code for like this

function delete_product_images( $post_id )
{
$product = wc_get_product( $post_id );

if ( !$product ) {
return;
}

$featured_image_id = $product->get_image_id();
$image_galleries_id = $product->get_gallery_image_ids();

if( !empty( $featured_image_id ) ) {
wp_delete_post( $featured_image_id );
}

if( !empty( $image_galleries_id ) ) {
foreach( $image_galleries_id as $single_image_id ) {
wp_delete_post( $single_image_id );
}
}
}

Hakik Zaman

Hi Ercan,

Unfortunately, the feature is not currently available.

​But it’s a great idea. Please send the feature request here: https://storepress.fider.io/

and ask your other to upvote it.

Cheers!