How to Add a Surcharge Percentage to A...
Enhance your WooCommerce store with this code snippet to easily add a surcharge perce...

WPCodeBox
598
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.";





