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,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();