Allow parent:0 param passing when updating a term via the API

This commit is contained in:
Gerhard Potgieter 2018-05-02 08:44:06 +02:00
parent 2124972232
commit 61e624b937
1 changed files with 4 additions and 0 deletions

View File

@ -491,6 +491,10 @@ abstract class WC_REST_Terms_Controller extends WC_REST_Controller {
$prepared_args['slug'] = $request['slug'];
}
if ( isset( $request['parent'] ) && 0 === $request['parent'] ) {
unset( $request['parent'] );
}
if ( isset( $request['parent'] ) ) {
if ( ! is_taxonomy_hierarchical( $taxonomy ) ) {
return new WP_Error( 'woocommerce_rest_taxonomy_not_hierarchical', __( 'Can not set resource parent, taxonomy is not hierarchical.', 'woocommerce' ), array( 'status' => 400 ) );