WC_REST_Product_Reviews_V2_Controller::batch_items()
Bulk create, update and delete items.
Method of the class: WC_REST_Product_Reviews_V2_Controller{}
No Hooks.
Return
Array
. Of WP_Error or WP_REST_Response.
Usage
$WC_REST_Product_Reviews_V2_Controller = new WC_REST_Product_Reviews_V2_Controller(); $WC_REST_Product_Reviews_V2_Controller->batch_items( $request );
- $request(WP_REST_Request) (required)
- Full details about the request.
Changelog
Since 3.0.0 | Introduced. |
WC_REST_Product_Reviews_V2_Controller::batch_items() WC REST Product Reviews V2 Controller::batch items code WC 9.8.1
public function batch_items( $request ) { $items = array_filter( $request->get_params() ); $params = $request->get_url_params(); $product_id = $params['product_id']; $body_params = array(); foreach ( array( 'update', 'create', 'delete' ) as $batch_type ) { if ( ! empty( $items[ $batch_type ] ) ) { $injected_items = array(); foreach ( $items[ $batch_type ] as $item ) { $injected_items[] = is_array( $item ) ? array_merge( array( 'product_id' => $product_id ), $item ) : $item; } $body_params[ $batch_type ] = $injected_items; } } $request = new WP_REST_Request( $request->get_method() ); $request->set_body_params( $body_params ); return parent::batch_items( $request ); }