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.
Return Return
(int)
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;
}