Automattic\WooCommerce\Blocks\Domain\Services

CheckoutFields::sync_order_additional_fields_with_customer()publicWC 1.0

Copies additional fields from a customer to an order.

Метод класса: CheckoutFields{}

Хуков нет.

Возвращает

null. Ничего (null).

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

$CheckoutFields = new CheckoutFields();
$CheckoutFields->sync_order_additional_fields_with_customer( $order, $customer );
$order(WC_Order) (обязательный)
The order to sync the fields for.
$customer(WC_Customer) (обязательный)
The customer to sync the fields for.

Код CheckoutFields::sync_order_additional_fields_with_customer() WC 9.6.0

public function sync_order_additional_fields_with_customer( WC_Order $order, WC_Customer $customer ) {
	foreach ( $this->groups as $group ) {
		$customer_additional_fields = $this->get_all_fields_from_object( $customer, $group, true );

		// Sync order additional fields with customer additional fields.
		foreach ( $customer_additional_fields as $key => $value ) {
			if ( $this->is_field( $key ) ) {
				$this->persist_field_for_order( $key, $value, $order, $group, false );
			}
		}
	}
}