Allowing API deletion of grouped products. #20666
This commit is contained in:
parent
920eb551a6
commit
c94a5df7a4
|
@ -1359,10 +1359,12 @@ class WC_REST_Products_Controller extends WC_REST_Legacy_Products_Controller {
|
||||||
} elseif ( $object->is_type( 'grouped' ) ) {
|
} elseif ( $object->is_type( 'grouped' ) ) {
|
||||||
foreach ( $object->get_children() as $child_id ) {
|
foreach ( $object->get_children() as $child_id ) {
|
||||||
$child = wc_get_product( $child_id );
|
$child = wc_get_product( $child_id );
|
||||||
|
if ( ! empty( $child ) ) {
|
||||||
$child->set_parent_id( 0 );
|
$child->set_parent_id( 0 );
|
||||||
$child->save();
|
$child->save();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
$object->delete( true );
|
$object->delete( true );
|
||||||
$result = 0 === $object->get_id();
|
$result = 0 === $object->get_id();
|
||||||
|
|
Loading…
Reference in New Issue