WC_Product_Data_Store_CPT::get_shipping_class_id_by_slug()publicWC 3.0.0

Get shipping class ID by slug.

Method of the class: WC_Product_Data_Store_CPT{}

No Hooks.

Return

Int|false.

Usage

$WC_Product_Data_Store_CPT = new WC_Product_Data_Store_CPT();
$WC_Product_Data_Store_CPT->get_shipping_class_id_by_slug( $slug );
$slug(string) (required)
Product shipping class slug.

Changelog

Since 3.0.0 Introduced.

WC_Product_Data_Store_CPT::get_shipping_class_id_by_slug() code WC 8.6.1

public function get_shipping_class_id_by_slug( $slug ) {
	$shipping_class_term = get_term_by( 'slug', $slug, 'product_shipping_class' );
	if ( $shipping_class_term ) {
		return $shipping_class_term->term_id;
	} else {
		return false;
	}
}