Při ukládání produktu mu přiřadím třídu dopravy Default, pokud není žádná třída vybraná.
<?php
function gog_set_default_shipping_class($product_id) {
$shipping_class = get_the_terms($product_id, 'product_shipping_class');
if (empty($shipping_class)) {
wp_set_object_terms($product_id, array('default'), 'product_shipping_class');
}
}
add_action('woocommerce_update_product', 'gog_set_default_shipping_class', 10, 1);