parent
e124841cbf
commit
0f54e57093
|
@ -283,6 +283,20 @@ class WC_Product_CSV_Importer extends WC_Product_Importer {
|
||||||
return floatval( $value );
|
return floatval( $value );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Parse the stock qty field.
|
||||||
|
*
|
||||||
|
* @param string $value Field value.
|
||||||
|
* @return float|string
|
||||||
|
*/
|
||||||
|
public function parse_stock_quantity_field( $value ) {
|
||||||
|
if ( '' === $value ) {
|
||||||
|
return $value;
|
||||||
|
}
|
||||||
|
|
||||||
|
return wc_stock_amount( $value );
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Parse a category field from a CSV.
|
* Parse a category field from a CSV.
|
||||||
* Categories are separated by commas and subcategories are "parent > subcategory".
|
* Categories are separated by commas and subcategories are "parent > subcategory".
|
||||||
|
@ -488,7 +502,7 @@ class WC_Product_CSV_Importer extends WC_Product_Importer {
|
||||||
'purchase_note' => 'wp_filter_post_kses',
|
'purchase_note' => 'wp_filter_post_kses',
|
||||||
'price' => 'wc_format_decimal',
|
'price' => 'wc_format_decimal',
|
||||||
'regular_price' => 'wc_format_decimal',
|
'regular_price' => 'wc_format_decimal',
|
||||||
'stock_quantity' => 'wc_stock_amount',
|
'stock_quantity' => array( $this, 'parse_stock_quantity_field' ),
|
||||||
'category_ids' => array( $this, 'parse_categories_field' ),
|
'category_ids' => array( $this, 'parse_categories_field' ),
|
||||||
'tag_ids' => array( $this, 'parse_tags_field' ),
|
'tag_ids' => array( $this, 'parse_tags_field' ),
|
||||||
'shipping_class_id' => array( $this, 'parse_shipping_class_field' ),
|
'shipping_class_id' => array( $this, 'parse_shipping_class_field' ),
|
||||||
|
@ -584,7 +598,13 @@ class WC_Product_CSV_Importer extends WC_Product_Importer {
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( isset( $data['stock_quantity'] ) ) {
|
if ( isset( $data['stock_quantity'] ) ) {
|
||||||
$data['manage_stock'] = 0 < $data['stock_quantity'];
|
if ( '' === $data['stock_quantity'] ) {
|
||||||
|
$data['manage_stock'] = false;
|
||||||
|
$data['stock_status'] = isset( $data['stock_status'] ) ? $data['stock_status'] : true;
|
||||||
|
} else {
|
||||||
|
$data['manage_stock'] = true;
|
||||||
|
$data['stock_status'] = 0 < $data['stock_quantity'];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Stock is bool.
|
// Stock is bool.
|
||||||
|
|
Loading…
Reference in New Issue