Moved hook like in master v3
This commit is contained in:
parent
4ba989a07e
commit
1d0bd12a46
|
@ -196,13 +196,6 @@ abstract class WC_REST_CRUD_Controller extends WC_REST_Posts_Controller {
|
|||
|
||||
try {
|
||||
$this->update_additional_fields_for_object( $object, $request );
|
||||
} catch ( WC_Data_Exception $e ) {
|
||||
$object->delete();
|
||||
return new WP_Error( $e->getErrorCode(), $e->getMessage(), $e->getErrorData() );
|
||||
} catch ( WC_REST_Exception $e ) {
|
||||
$object->delete();
|
||||
return new WP_Error( $e->getErrorCode(), $e->getMessage(), array( 'status' => $e->getCode() ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Fires after a single object is created or updated via the REST API.
|
||||
|
@ -212,6 +205,13 @@ abstract class WC_REST_CRUD_Controller extends WC_REST_Posts_Controller {
|
|||
* @param boolean $creating True when creating object, false when updating.
|
||||
*/
|
||||
do_action( "woocommerce_rest_insert_{$this->post_type}_object", $object, $request, true );
|
||||
} catch ( WC_Data_Exception $e ) {
|
||||
$object->delete();
|
||||
return new WP_Error( $e->getErrorCode(), $e->getMessage(), $e->getErrorData() );
|
||||
} catch ( WC_REST_Exception $e ) {
|
||||
$object->delete();
|
||||
return new WP_Error( $e->getErrorCode(), $e->getMessage(), array( 'status' => $e->getCode() ) );
|
||||
}
|
||||
|
||||
$request->set_param( 'context', 'edit' );
|
||||
$response = $this->prepare_object_for_response( $object, $request );
|
||||
|
@ -243,11 +243,6 @@ abstract class WC_REST_CRUD_Controller extends WC_REST_Posts_Controller {
|
|||
|
||||
try {
|
||||
$this->update_additional_fields_for_object( $object, $request );
|
||||
} catch ( WC_Data_Exception $e ) {
|
||||
return new WP_Error( $e->getErrorCode(), $e->getMessage(), $e->getErrorData() );
|
||||
} catch ( WC_REST_Exception $e ) {
|
||||
return new WP_Error( $e->getErrorCode(), $e->getMessage(), array( 'status' => $e->getCode() ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Fires after a single object is created or updated via the REST API.
|
||||
|
@ -257,6 +252,11 @@ abstract class WC_REST_CRUD_Controller extends WC_REST_Posts_Controller {
|
|||
* @param boolean $creating True when creating object, false when updating.
|
||||
*/
|
||||
do_action( "woocommerce_rest_insert_{$this->post_type}_object", $object, $request, false );
|
||||
} catch ( WC_Data_Exception $e ) {
|
||||
return new WP_Error( $e->getErrorCode(), $e->getMessage(), $e->getErrorData() );
|
||||
} catch ( WC_REST_Exception $e ) {
|
||||
return new WP_Error( $e->getErrorCode(), $e->getMessage(), array( 'status' => $e->getCode() ) );
|
||||
}
|
||||
|
||||
$request->set_param( 'context', 'edit' );
|
||||
$response = $this->prepare_object_for_response( $object, $request );
|
||||
|
|
Loading…
Reference in New Issue