Easy methods to Appropriately Take away Woocommerce from WordPress (with product photos)?

On this video I’m going to point out you how you can appropriately take away Woocommerce from WordPress in a manner that it’ll not depart any mess behind. It signifies that all of the product photos shall be eliminated together with it.

So, first I’d recommend you to try the video right here beneath, after which precisely what to do.

Video: Easy methods to Appropriately Take away Woocommerce from WordPress?

Code snippet for possibility 1

outline( 'WC_REMOVE_ALL_DATA', true );

Code snippet for possibility 3

// Robotically Delete Woocommerce Photos After Deleting a Product
add_action( 'before_delete_post', 'delete_product_images', 10, 1 );

operate 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 );
        }
    }
}

Helpful Woocommerce ideas

  • Easy methods to Customise Woocommerce Checkout web page? 28 helpful hacks

  • Easy methods to customise Woocommerce cart web page? 21 helpful Woocommerce Cart Web page Hacks

  • Woocommerce – Disable Fee Strategies Primarily based on Person Roles

  • Easy methods to promote tickets with Woocommerce?

  • Easy methods to add Woocommerce Amount Selector in Archive/Loop pages?

  • Easy methods to promote tickets with Woocommerce?

  • 12 helpful Woocommerce snippets & hacks

Leave a Comment

Your email address will not be published. Required fields are marked *

Shopping Cart
Scroll to Top