$getter(); if ( $skip_empty && '' === $value ) { continue; } $customer->$setter( $value ); $written[] = "{$type}_{$field}"; } $customer->save(); /** * Fires after an order address has been copied to a customer profile. * * @since 1.0.0 * @param int $user_id Customer ID. * @param WC_Order $order Source order. * @param string $type billing|shipping. * @param string[] $written Written field keys. */ do_action( 'apwc_order_address_copied', $user_id, $order, $type, $written ); return $written; } /** * One-line formatted address for a user, or empty string. * * @since 1.0.0 * @param int $user_id User ID. * @param string $type billing|shipping. * @return string */ public static function format_for_user( $user_id, $type ) { $parts = array(); foreach ( array( 'first_name', 'last_name', 'company', 'address_1', 'address_2', 'city', 'state', 'postcode', 'country' ) as $field ) { $parts[ $field ] = (string) get_user_meta( $user_id, "{$type}_{$field}", true ); } if ( '' === implode( '', $parts ) ) { return ''; } return WC()->countries->get_formatted_address( $parts, ', ' ); } }