WordPress at a glance
function is not described

WC_REST_Orders_V2_Controller::prepare_shipping_lines() protected WC 1.0

Create or update an order shipping method.

{} It's a method of the class: WC_REST_Orders_V2_Controller{}

No Hooks.

Return

WC_Order_Item_Shipping.

Usage

// protected - for code of main (parent) or child class
$result = $this->prepare_shipping_lines( $posted, $action, $item );
$posted(array) (required)
$shipping Item data.
$action(string)
'create' to add shipping or 'update' to update it.
$item(object)
Passed when updating an item. Null during creation.

Code of WC_REST_Orders_V2_Controller::prepare_shipping_lines() WC 5.0.0

<?php
protected function prepare_shipping_lines( $posted, $action = 'create', $item = null ) {
	$item = is_null( $item ) ? new WC_Order_Item_Shipping( ! empty( $posted['id'] ) ? $posted['id'] : '' ) : $item;

	if ( 'create' === $action ) {
		if ( empty( $posted['method_id'] ) ) {
			throw new WC_REST_Exception( 'woocommerce_rest_invalid_shipping_item', __( 'Shipping method ID is required.', 'woocommerce' ), 400 );
		}
	}

	$this->maybe_set_item_props( $item, array( 'method_id', 'method_title', 'total', 'instance_id' ), $posted );
	$this->maybe_set_item_meta_data( $item, $posted );

	return $item;
}