Automattic\WooCommerce\Internal\Orders

OrderAttributionController::set_order_source_dataprivateWC 1.0

Save source data for an Order object.

Method of the class: OrderAttributionController{}

No Hooks.

Returns

null. Nothing (null).

Usage

// private - for code of main (parent) class only
$result = $this->set_order_source_data( $source_data, $order );
$source_data(array) (required)
The source data.
$order(WC_Order) (required)
The order object.

OrderAttributionController::set_order_source_data() code WC 9.8.5

private function set_order_source_data( array $source_data, WC_Order $order ) {
	// If all the values are empty, bail.
	if ( empty( array_filter( $source_data ) ) ) {
		return;
	}
	foreach ( $source_data as $key => $value ) {
		$order->add_meta_data( $this->get_meta_prefixed_field_name( $key ), $value );
	}

	$order->save_meta_data();
}