Automattic\WooCommerce\Admin\API
Notes::batch_update_items()
Batch update a set of notes.
Метод класса: Notes{}
Хуков нет.
Возвращает
WP_REST_Request|WP_Error
.
Использование
$Notes = new Notes(); $Notes->batch_update_items( $request );
- $request(WP_REST_Request) (обязательный)
- Request object.
Код Notes::batch_update_items() Notes::batch update items WC 9.3.3
public function batch_update_items( $request ) { $data = array(); $note_ids = $request->get_param( 'noteIds' ); if ( ! isset( $note_ids ) || ! is_array( $note_ids ) ) { return new \WP_Error( 'woocommerce_note_invalid_ids', __( 'Please provide an array of IDs through the noteIds param.', 'woocommerce' ), array( 'status' => 422 ) ); } foreach ( (array) $note_ids as $note_id ) { $note = NotesRepository::get_note( (int) $note_id ); if ( $note ) { NotesRepository::update_note( $note, $this->get_requested_updates( $request ) ); $data[] = $this->prepare_note_data_for_response( $note, $request ); } } $response = rest_ensure_response( $data ); $response->header( 'X-WP-Total', NotesRepository::get_notes_count( array( 'info', 'warning' ), array() ) ); return $response; }