Automattic\WooCommerce\Blocks\Domain\Services

CheckoutFields::persist_field_for_order()publicWC 1.0

Persists a field value for a given order. This would also optionally set the field value on the customer object if the order is linked to a registered customer.

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

Хуков нет.

Возвращает

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

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

$CheckoutFields = new CheckoutFields();
$CheckoutFields->persist_field_for_order( $key, $value, $order, $group, $set_customer );
$key(строка) (обязательный)
The field key.
$value(разное) (обязательный)
The field value.
$order(WC_Order) (обязательный)
The order to persist the field for.
$group(строка)
The group to persist the field for (shipping|billing|other).
По умолчанию: 'other'
$set_customer(true|false)
Whether to set the field value on the customer or not.
По умолчанию: true

Код CheckoutFields::persist_field_for_order() WC 9.5.1

public function persist_field_for_order( string $key, $value, WC_Order $order, string $group = 'other', bool $set_customer = true ) {
	if ( 'additional' === $group ) {
		wc_deprecated_argument( 'group', '8.9.0', 'The "additional" group is deprecated. Use "other" instead.' );
		$group = 'other';
	}

	$this->set_array_meta( $key, $value, $order, $group );
	if ( $set_customer && $order->get_customer_id() ) {
		$customer = new WC_Customer( $order->get_customer_id() );
		$this->persist_field_for_customer( $key, $value, $customer, $group );
	}
}