I use following code on external script to retrieve all products (simple and variable):
$args = array(
\'post_type\' => array(\'product\', \'pro
I have modified your code. Try following ---
$args = array(
'post_type' => array('product', 'product_variation'),
'numberposts' => -1,
'post_status' => 'publish',
);
$shop_products = get_posts( $args );
foreach ($shop_products as $item) {
$product = wc_get_product($item->ID);
echo $item->ID.": shipping class is -> ".$product->get_shipping_class()."<br>";
}