Fix product csv exporter get stock value

seems the original get stock value is wrong, but I'm not sure if my change is correct...
what i'm considering is this line:  if ( $product->is_type( 'variation' && 'parent' === $manage_stock ) ) {
This commit is contained in:
ldybecklee 2018-07-11 17:28:50 +08:00 committed by GitHub
parent 1ef4aa10a0
commit 327fd26c70
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 9 additions and 5 deletions

View File

@ -399,14 +399,18 @@ class WC_Product_CSV_Exporter extends WC_CSV_Batch_Exporter {
$manage_stock = $product->get_manage_stock( 'edit' ); $manage_stock = $product->get_manage_stock( 'edit' );
$stock_quantity = $product->get_stock_quantity( 'edit' ); $stock_quantity = $product->get_stock_quantity( 'edit' );
if ( $product->is_type( 'variation' && 'parent' === $manage_stock ) ) { if ( $manage_stock ) {
return 'parent';
} elseif ( $manage_stock ) {
return $stock_quantity; return $stock_quantity;
} else { } else if ( $product->is_type( 'variation' ) ) {
return ''; if ( $product->get_parent_id( 'edit' ) ) {
$parent = wc_get_product( $product->get_parent_id( 'edit' ) );
if( $parent->get_manage_stock( 'edit' ) ) {
return 'parent';
} }
} }
}
return '';
}
/** /**
* Get stock status value. * Get stock status value.