Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: readonly address error #863

Open
wants to merge 12 commits into
base: main
Choose a base branch
from
16 changes: 16 additions & 0 deletions apps/web/composables/useAddressV2/useCheckoutAddress.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,24 @@ export const useCheckoutAddress = (type: AddressType) => {
await setCheckoutAddress(address);
};

const handleGuestAddressCleanup = (addressId: number) => {
const addressType = type === AddressType.Shipping ? AddressType.Billing : AddressType.Shipping;
const { hasCheckoutAddress: hasAddress, clear: clearAddress } = useCheckoutAddress(addressType);
const { get: getAddress, destroy: destroyAddress } = useAddressStore(addressType);

if (hasAddress.value) clearAddress();
if (getAddress(addressId) !== undefined) destroyAddress(addressId);
};

const clear = () => {
const { shippingAsBilling } = useShippingAsBilling();
const { isGuest } = useCustomer();

const addressId = state.value.checkoutAddress?.id;
state.value.checkoutAddress = {} as Address;

if (!addressId || !isGuest.value || !shippingAsBilling.value) return;
handleGuestAddressCleanup(addressId);
};

const hasCheckoutAddress = computed(() => {
Expand Down
1 change: 1 addition & 0 deletions docs/changelog/changelog_en.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ NPM_AUTH_TOKEN="<TOKEN>"

### 🩹 Fixed

- Addressed a scenario where deleting the checkout address as a guest triggered an unknown error.
- Added no-preflight class to prevent tailwind preflight for content coming from backend editor.
- Adjusted the checkout layout for tablet screen sizes.
- Changed image quality in quick checkout to use middle image and positioned quantity.
Expand Down
Loading