Skip to content

Commit

Permalink
Merge pull request scandipwa#5248 from AleksandrsKondratjevs/issue-5244
Browse files Browse the repository at this point in the history
issue-5244 - Fix cart adding to cart flow && opening checkout with saved address
  • Loading branch information
AleksandrsKondratjevs authored Oct 28, 2022
2 parents 9d52635 + 7a221dd commit 9e8ded3
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,7 @@ export class CheckoutAddressTableComponent extends MyAccountAddressTable<Checkou
isSelected: false,
};

__construct(props: CheckoutAddressTableComponentProps): void {
this.__construct?.(props);

__construct(): void {
this.onAddressClick = this.onAddressClick.bind(this);
}

Expand Down
40 changes: 22 additions & 18 deletions packages/scandipwa/src/store/Cart/Cart.dispatcher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,14 +59,7 @@ export class CartDispatcher {
cartData: {
is_virtual = false,
shipping_addresses: [{
selected_shipping_method: {
address,
address: {
street = null,
email = '',
} = {},
method_code = '',
} = {},
selected_shipping_method = null,
} = {}] = [],
} = {},
} = await fetchQuery(
Expand All @@ -75,17 +68,28 @@ export class CartDispatcher {
),
);

if (address && street) {
if (!is_virtual) {
await dispatch(
updateShippingFields({
...this.prepareCheckoutAddressFormat(address as CartAddress),
method_code,
}),
);
if (selected_shipping_method) {
const {
address,
address: {
email = '',
street = '',
} = {},
method_code = '',
} = selected_shipping_method;

if (address && street) {
if (!is_virtual) {
await dispatch(
updateShippingFields({
...this.prepareCheckoutAddressFormat(address as CartAddress),
method_code,
}),
);
}

await dispatch(updateEmail(email));
}

await dispatch(updateEmail(email));
}

if (isForCustomer && !getAuthorizationToken()) {
Expand Down

0 comments on commit 9e8ded3

Please sign in to comment.