How to Remove Product Image Thumbnail ...
Prevent accidental lightbox pop-ups! This WooCommerce code snippet helps website owne...

WPCodeBox
418

This snippet queries the WordPress database to find and count orphaned WooCommerce product variations, which are product variations whose main product has been deleted.
<?php
// This snippet should only run in "Manual" mode.
global $wpdb;
$orphaned_variations_results = $wpdb->get_results("SELECT * FROM {$wpdb->posts} o LEFT OUTER JOIN {$wpdb->posts} r ON o.post_parent = r.ID WHERE r.id IS null AND o.post_type = 'product_variation'");
$ov_count = count($orphaned_variations_results);
echo "There are $ov_count variations on your site.";





