WC_Product_CSV_Importer::parse_shipping_class_field( string $value )

Parse a shipping class field from a CSV.


Description Description


Parameters Parameters

$value

(Required) Field value.


Top ↑

Return Return

(int)


Top ↑

Source Source

File: includes/import/class-wc-product-csv-importer.php

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

Top ↑

User Contributed Notes User Contributed Notes

You must log in before being able to contribute a note or feedback.