WC_Product_CSV_Importer::parse_shipping_class_field()publicWC 1.0

Parse a shipping class field from a CSV.

{} Это метод класса: WC_Product_CSV_Importer{}

Хуков нет.

Возвращает

int.

Использование

$WC_Product_CSV_Importer = new WC_Product_CSV_Importer();
$WC_Product_CSV_Importer->parse_shipping_class_field( $value );
$value(строка) (обязательный)
Field value.

Код WC_Product_CSV_Importer::parse_shipping_class_field() WC 6.9.4

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;
}