Persist makePrimaryShippingAddress
and makePrimaryBillingAddress
on carts
#3864
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
When choosing addresses from a customer's address book to use as the addresses on the cart,
billingAddressId
orshippingAddressId
are submitted.Optionally, you can also pass
makePrimaryShippingAddress
ormakePrimaryBillingAddress
, which allows the customer to make these submitted addresses the new primary addresses in their address book.Alternatively, instead of submitting address IDs from the address book, the customer can submit a new address directly to the cart. This address would only exist on the order and would not be added to the address book, even after checkout. However, customers requested the ability to collect a new address and have it added to the address book after checkout.
To address this, we introduced cart parameters called
saveBillingAddressOnOrderComplete
andsaveShippingAddressOnOrderComplete
. These parameters can be added to the cart so that, when the order is completed, the addresses on the order are copied to the customer's address book.The issue this PR fixes is related to the behavior of copying these addresses to the address book. Now, when this copy occurs, we will check the
makePrimaryShippingAddress
ormakePrimaryBillingAddress
flags to determine whether the copied addresses should become the primary addresses in the address book. Previously, these flags only worked when selecting an existing address from the address book.The
makePrimaryShippingAddress
ormakePrimaryBillingAddress
were previously never persisted to the order record but they are now in this PR. This means during checkout the developer can know the customers selection during checkout (since previously they only existed as options within a single cart update request).