WC_REST_Setting_Options_V2_Controller::batch_items() public WC 3.0.0
Bulk create, update and delete items.
{} It's a method of the class: WC_REST_Setting_Options_V2_Controller{}
No Hooks.
Return
Array. Of WP_Error or WP_REST_Response.
Usage
$WC_REST_Setting_Options_V2_Controller = new WC_REST_Setting_Options_V2_Controller(); $WC_REST_Setting_Options_V2_Controller->batch_items( $request );
- $request(WP_REST_Request) (required)
- Full details about the request.
Changelog
Since 3.0.0 | Introduced. |
Code of WC_REST_Setting_Options_V2_Controller::batch_items() WC REST Setting Options V2 Controller::batch items WC 5.0.0
public function batch_items( $request ) {
// Get the request params.
$items = array_filter( $request->get_params() );
/*
* Since our batch settings update is group-specific and matches based on the route,
* we inject the URL parameters (containing group) into the batch items
*/
if ( ! empty( $items['update'] ) ) {
$to_update = array();
foreach ( $items['update'] as $item ) {
$to_update[] = array_merge( $request->get_url_params(), $item );
}
$request = new WP_REST_Request( $request->get_method() );
$request->set_body_params( array( 'update' => $to_update ) );
}
return parent::batch_items( $request );
}