Automattic\WooCommerce\Blocks\Domain\Services
CheckoutFields::sync_customer_additional_fields_with_order
Copies additional fields from an order to a customer.
Method of the class: CheckoutFields{}
No Hooks.
Returns
null. Nothing (null).
Usage
$CheckoutFields = new CheckoutFields(); $CheckoutFields->sync_customer_additional_fields_with_order( $order, $customer );
- $order(WC_Order) (required)
- The order to sync the fields for.
- $customer(WC_Customer) (required)
- The customer to sync the fields for.
CheckoutFields::sync_customer_additional_fields_with_order() CheckoutFields::sync customer additional fields with order code WC 10.8.1
public function sync_customer_additional_fields_with_order( WC_Order $order, WC_Customer $customer ) {
foreach ( $this->groups as $group ) {
$order_additional_fields = $this->get_all_fields_from_object( $order, $group, true );
// Sync customer additional fields with order additional fields.
foreach ( $order_additional_fields as $key => $value ) {
if ( $this->is_customer_field( $key ) ) {
$this->persist_field_for_customer( $key, $value, $customer, $group );
}
}
}
}