WordPress at Your Fingertips
function is not described

WC_API_Orders::set_order_meta() protected WC 2.2

Helper method to add/update order meta, with two restrictions:

1) Only non-protected meta (no leading underscore) can be set
2) Meta values must be scalar (int, string, bool)

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

No Hooks.

Return

null. Nothing.

Usage

// protected - for code of main (parent) or child class
$result = $this->set_order_meta( $order_id, $order_meta );
$order_id(int) (required)
valid order ID
$order_meta(array) (required)
order meta in array( 'meta_key' => 'meta_value' ) format

Changelog

Since 2.2 Introduced.

Code of WC_API_Orders::set_order_meta() WC 5.6.0

protected function set_order_meta( $order_id, $order_meta ) {

	foreach ( $order_meta as $meta_key => $meta_value ) {

		if ( is_string( $meta_key ) && ! is_protected_meta( $meta_key ) && is_scalar( $meta_value ) ) {
			update_post_meta( $order_id, $meta_key, $meta_value );
		}
	}
}