Skip to content

Commit

Permalink
Merge pull request #2300 from graphcommerce-org/fix/GCOM-1430
Browse files Browse the repository at this point in the history
Fixed CustomerAddressForm resetting to a saved address when trying to use a new address
  • Loading branch information
paales authored Jun 28, 2024
2 parents 52f7cb2 + 19adebe commit bb0a127
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 5 deletions.
5 changes: 5 additions & 0 deletions .changeset/khaki-pianos-cry.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@graphcommerce/magento-cart-shipping-address": patch
---

Fixed CustomerAddressForm resetting to a saved address when trying to use a new address
Original file line number Diff line number Diff line change
Expand Up @@ -107,18 +107,24 @@ export function CustomerAddressForm(props: CustomerAddressListProps) {

useEffect(() => {
if (mode === 'both' || mode === 'shipping') {
if (!cartAddressId && defaultShippingId) {
// console.log('shippingAddress.customer_address_id', defaultShippingId)
if (!cartAddressId && !cartShipping && defaultShippingId) {
setValue('customer_address_id', defaultShippingId, { shouldValidate: true })
}
}
if (mode === 'billing') {
if (!cartAddressId && defaultBillingId) {
// console.log('billingAddress.customer_address_id', defaultBillingId)
if (!cartAddressId && !cartBilling && defaultBillingId) {
setValue('customer_address_id', defaultBillingId, { shouldValidate: true })
}
}
}, [cartAddressId, defaultBillingId, defaultShippingId, mode, setValue])
}, [
cartAddressId,
cartBilling,
cartShipping,
defaultBillingId,
defaultShippingId,
mode,
setValue,
])

const submit = handleSubmit(() => {})

Expand Down

0 comments on commit bb0a127

Please sign in to comment.