WC_REST_Orders_V2_Controller::maybe_set_item_prop()protectedWC 1.0

Maybe set an item prop if the value was posted.

Method of the class: WC_REST_Orders_V2_Controller{}

No Hooks.

Return

null. Nothing (null).

Usage

// protected - for code of main (parent) or child class
$result = $this->maybe_set_item_prop( $item, $prop, $posted );
$item(WC_Order_Item) (required)
Order item.
$prop(string) (required)
Order property.
$posted(array) (required)
Request data.

WC_REST_Orders_V2_Controller::maybe_set_item_prop() code WC 8.9.0

protected function maybe_set_item_prop( $item, $prop, $posted ) {
	if ( isset( $posted[ $prop ] ) ) {
		$item->{"set_$prop"}( $posted[ $prop ] );
	}
}