woocommerce_rest_insert_product

woocommerce_rest_insert_product

Appears in: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , ,
Hook Type: action
See hook in action

See hook in core

Displaying hooks found in version: woocommerce.9.8.1

do_action('woocommerce_rest_insert_product') is found 2 times:

  • /includes/rest-api/Controllers/Version1/class-wc-rest-products-v1-controller.php line 764
    760
    761
    762
    763
    764
    765
    766
    767
    768
    769
    * @param WP_Post         $post      Post data.
     * @param WP_REST_Request $request   Request object.
     * @param boolean         $creating  True when creating item, false when updating.
     */
    do_action( 'woocommerce_rest_insert_product', $post, $request, true );
    $request->set_param( 'context', 'edit' );
    $response = $this->prepare_item_for_response( $post, $request );
    $response = rest_ensure_response( $response );
    $response->set_status( 201 );
    $response->header( 'Location', rest_url( sprintf( '/%s/%s/%d', $this->namespace, $this->rest_base, $post->ID ) ) );
  • /includes/rest-api/Controllers/Version1/class-wc-rest-products-v1-controller.php line 807
    803
    804
    805
    806
    807
    808
    809
    810
    811
    812
    813
         * @param WP_Post         $post      Post data.
         * @param WP_REST_Request $request   Request object.
         * @param boolean         $creating  True when creating item, false when updating.
         */
        do_action( 'woocommerce_rest_insert_product', $post, $request, false );
        $request->set_param( 'context', 'edit' );
        $response = $this->prepare_item_for_response( $post, $request );
     
        return rest_ensure_response( $response );
    } catch ( WC_Data_Exception $e ) {
        return new WP_Error( $e->getErrorCode(), $e->getMessage(), $e->getErrorData() );

See this hook used in plugins: