Fix: variations exported as draft were imported as draft (#36933)
* Fix: variations exported as draft were imported as draft * Add changelog file * Fix "ArrayUtil::get_value_or_default" for existing keys with null values Now ArrayUtil::get_value_or_default($array, $key, $default) will return null, instead of $default, when $array[$key] exists and is null. * Undo the change to ArrayUtil (will get its own PR)
This commit is contained in:
parent
81fdbe3125
commit
8786c19b74
|
@ -0,0 +1,4 @@
|
|||
Significance: patch
|
||||
Type: fix
|
||||
|
||||
Fix variations exported as draft being imported as draft (and thus remaining invisible)
|
|
@ -843,15 +843,20 @@ class WC_Product_CSV_Importer extends WC_Product_Importer {
|
|||
|
||||
// Status is mapped from a special published field.
|
||||
if ( isset( $data['published'] ) ) {
|
||||
$published = $data['published'];
|
||||
if ( is_float( $published ) ) {
|
||||
$published = (int) $published;
|
||||
}
|
||||
|
||||
$statuses = array(
|
||||
-1 => 'draft',
|
||||
0 => 'private',
|
||||
1 => 'publish',
|
||||
);
|
||||
$data['status'] = isset( $statuses[ $data['published'] ] ) ? $statuses[ $data['published'] ] : 'draft';
|
||||
$data['status'] = $statuses[ $published ] ?? 'draft';
|
||||
|
||||
// Fix draft status of variations.
|
||||
if ( isset( $data['type'] ) && 'variation' === $data['type'] && -1 === $data['published'] ) {
|
||||
if ( 'variation' === ( $data['type'] ?? null ) && -1 === $published ) {
|
||||
$data['status'] = 'publish';
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue