Automattic\WooCommerce\Blocks\Domain\Services
CheckoutFields::persist_field_for_order
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() CheckoutFields::persist field for order WC 10.3.6
public function persist_field_for_order( string $key, $value, WC_Order $order, string $group = 'other', bool $set_customer = true ) {
$group = $this->prepare_group_name( $group );
$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 );
}
}