Skip to content

Commit f5e79ed

Browse files
committed
fix(checkout): find addresses with numeric id
user addresses are returned by the backend with addressId being of type `number` but for some reason we were looking for them using the addressId casted to `string`, so they were never found. userShippingGetters.getAddress matches criteria based on strict type checking `===` so that's why the eg. addressId String(131) did not match Number(131) M2-755
1 parent 505c6d8 commit f5e79ed

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

packages/theme/modules/checkout/pages/Checkout/Billing.vue

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -311,7 +311,7 @@ import type {
311311
ShippingCartAddress, BillingCartAddress, Country, Customer, CustomerAddress,
312312
} from '~/modules/GraphQL/types';
313313
314-
const NOT_SELECTED_ADDRESS = '';
314+
const NOT_SELECTED_ADDRESS = -1;
315315
316316
extend('required', {
317317
...required,
@@ -371,7 +371,7 @@ export default defineComponent({
371371
? addressFromApiToForm(billingAddress.value)
372372
: getInitialCheckoutAddressForm(),
373373
);
374-
const currentAddressId = ref(NOT_SELECTED_ADDRESS);
374+
const currentAddressId = ref<number>(NOT_SELECTED_ADDRESS);
375375
const setAsDefault = ref(false);
376376
const isFormSubmitted = ref(false);
377377
const canAddNewAddress = ref(true);
@@ -453,7 +453,7 @@ export default defineComponent({
453453
454454
const handleSetCurrentAddress = (addr: CustomerAddress) => {
455455
billingDetails.value = { ...addressFromApiToForm(addr) };
456-
currentAddressId.value = String(addr?.id);
456+
currentAddressId.value = addr?.id;
457457
canAddNewAddress.value = false;
458458
isBillingDetailsStepCompleted.value = false;
459459
};

packages/theme/modules/checkout/pages/Checkout/Shipping.vue

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -288,7 +288,7 @@ import { addressFromApiToForm, CheckoutAddressForm, getInitialCheckoutAddressFor
288288
import { mergeItem } from '~/helpers/asyncLocalStorage';
289289
import { isPreviousStepValid } from '~/helpers/checkout/steps';
290290
291-
const NOT_SELECTED_ADDRESS = '';
291+
const NOT_SELECTED_ADDRESS = -1;
292292
293293
extend('required', {
294294
...required,
@@ -339,7 +339,7 @@ export default defineComponent({
339339
const { isAuthenticated } = useUser();
340340
const shippingDetails = ref<CheckoutAddressForm>(address.value ? addressFromApiToForm(address.value) : getInitialCheckoutAddressForm());
341341
const shippingMethods = ref<AvailableShippingMethod[]>([]);
342-
const currentAddressId = ref(NOT_SELECTED_ADDRESS);
342+
const currentAddressId = ref<number>(NOT_SELECTED_ADDRESS);
343343
const setAsDefault = ref(false);
344344
const isFormSubmitted = ref(false);
345345
const canAddNewAddress = ref(true);
@@ -397,7 +397,7 @@ export default defineComponent({
397397
398398
const handleSetCurrentAddress = (addr: CustomerAddress) => {
399399
shippingDetails.value = { ...addressFromApiToForm(addr) };
400-
currentAddressId.value = String(addr?.id);
400+
currentAddressId.value = addr?.id;
401401
canAddNewAddress.value = false;
402402
isShippingDetailsStepCompleted.value = false;
403403
};

0 commit comments

Comments
 (0)