Get WooCommerce product shipping class name

/**
 * Returns the product shipping class name.
 *
 * @return string
 */
function get_shipping_class_name( $product_id ) {
	$classes = get_the_terms( $product_id, 'product_shipping_class' );
	return ( $classes && ! is_wp_error( $classes ) ) ? current( $classes )->name : '';
}

Leave a Comment