WordPress at Your Fingertips
function is not described

WC_Product_CSV_Importer::parse_shipping_class_field() public WC 1.0

Parse a shipping class field from a CSV.

{} It's a method of the class: WC_Product_CSV_Importer{}

No Hooks.

Return

Int.

Usage

$WC_Product_CSV_Importer = new WC_Product_CSV_Importer();
$WC_Product_CSV_Importer->parse_shipping_class_field( $value );
$value(string) (required)
Field value.

Code of WC_Product_CSV_Importer::parse_shipping_class_field() WC 5.7.1

public function parse_shipping_class_field( $value ) {
	if ( empty( $value ) ) {
		return 0;
	}

	$term = get_term_by( 'name', $value, 'product_shipping_class' );

	if ( ! $term || is_wp_error( $term ) ) {
		$term = (object) wp_insert_term( $value, 'product_shipping_class' );
	}

	if ( is_wp_error( $term ) ) {
		return 0;
	}

	return $term->term_id;
}