Skip to content

Commit 121ba8a

Browse files
committed
Populate fields with Address details, not Customer
We’ll be populating the fields using the Address data rather than Customer data for these 3 fields, for consistency with Android. There’s some inconsistency with the API though, reported here: #7993
1 parent 7b58531 commit 121ba8a

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

WooCommerce/Classes/ViewRelated/Orders/Order Details/Address Edit/AddressFormViewModelProtocol.swift

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -411,16 +411,19 @@ open class AddressFormViewModel: ObservableObject {
411411
}
412412

413413
private func fillCustomerFields(customer: Customer) {
414-
fields = populate(fields: fields, with: customer, address: customer.billing)
415-
secondaryFields = populate(fields: secondaryFields, with: customer, address: customer.shipping)
414+
fields = populate(fields: fields, with: customer.billing)
415+
secondaryFields = populate(fields: secondaryFields, with: customer.shipping)
416416
}
417417

418-
private func populate(fields: AddressFormFields, with customer: Customer, address: Address?) -> AddressFormFields {
418+
private func populate(fields: AddressFormFields, with address: Address?) -> AddressFormFields {
419419
var fields = fields
420420

421-
fields.firstName = customer.firstName ?? ""
422-
fields.lastName = customer.lastName ?? ""
423-
fields.email = customer.email
421+
fields.firstName = address?.firstName ?? ""
422+
fields.lastName = address?.lastName ?? ""
423+
// Email is declared optional because we're using the same property from the Address model
424+
// for both Shipping and Billing details:
425+
// https://github.com/woocommerce/woocommerce-ios/issues/7993
426+
fields.email = address?.email ?? ""
424427
fields.phone = address?.phone ?? ""
425428
fields.company = address?.company ?? ""
426429
fields.address1 = address?.address1 ?? ""

0 commit comments

Comments
 (0)