Allowing API deletion of grouped products. #20666

This commit is contained in:
Eleanor Martin 2018-06-29 15:01:10 +01:00
parent 920eb551a6
commit c94a5df7a4
1 changed files with 4 additions and 2 deletions

View File

@ -1359,8 +1359,10 @@ 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 );
$child->set_parent_id( 0 ); if ( ! empty( $child ) ) {
$child->save(); $child->set_parent_id( 0 );
$child->save();
}
} }
} }