WC_Product_Data_Store_CPT::get_shipping_class_id_by_slug
Get shipping class ID by slug.
Method of the class: WC_Product_Data_Store_CPT{}
No Hooks.
Returns
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() WC Product Data Store CPT::get shipping class id by slug code WC 10.3.3
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;
}
}