WordPress как на ладони
Недорогой хостинг для сайтов на WordPress: wordpress.jino.ru
функция не описана

WC_REST_Orders_V1_Controller::prepare_item_for_database() protected WC 1.0

Prepare a single order for create.

{} Это метод класса: WC_REST_Orders_V1_Controller{}

Хуки из метода
Возвращает

WP_Error/WC_Order. $data Object.

Использование

// protected - в коде основоного (родительского) или дочернего класса
$result = $this->prepare_item_for_database( $request );
$request(WP_REST_Request) (обязательный)
Request object.

Код WC_REST_Orders_V1_Controller::prepare_item_for_database() WC 4.7.0

<?php
protected function prepare_item_for_database( $request ) {
	$id        = isset( $request['id'] ) ? absint( $request['id'] ) : 0;
	$order     = new WC_Order( $id );
	$schema    = $this->get_item_schema();
	$data_keys = array_keys( array_filter( $schema['properties'], array( $this, 'filter_writable_props' ) ) );

	// Handle all writable props
	foreach ( $data_keys as $key ) {
		$value = $request[ $key ];

		if ( ! is_null( $value ) ) {
			switch ( $key ) {
				case 'billing' :
				case 'shipping' :
					$this->update_address( $order, $value, $key );
					break;
				case 'line_items' :
				case 'shipping_lines' :
				case 'fee_lines' :
				case 'coupon_lines' :
					if ( is_array( $value ) ) {
						foreach ( $value as $item ) {
							if ( is_array( $item ) ) {
								if ( $this->item_is_null( $item ) || ( isset( $item['quantity'] ) && 0 === $item['quantity'] ) ) {
									$order->remove_item( $item['id'] );
								} else {
									$this->set_item( $order, $key, $item );
								}
							}
						}
					}
					break;
				default :
					if ( is_callable( array( $order, "set_{$key}" ) ) ) {
						$order->{"set_{$key}"}( $value );
					}
					break;
			}
		}
	}

	/**
	 * Filter the data for the insert.
	 *
	 * The dynamic portion of the hook name, $this->post_type, refers to post_type of the post being
	 * prepared for the response.
	 *
	 * @param WC_Order           $order      The order object.
	 * @param WP_REST_Request    $request    Request object.
	 */
	return apply_filters( "woocommerce_rest_pre_insert_{$this->post_type}", $order, $request );
}