Skip to content

Commit e700ed1

Browse files
KevinGorjanMarcin Kwiatkowskibloodf
authored
fix: broken cart after placing order as guest (#386)
* fix(theme): passing the email instead of the user-object for creating a guest-cart * fix(composables): remove empty params in array, fails on Magento * test(theme): updated test for attaching guest email address to cart * Update packages/composables/src/composables/useShipping/index.ts Co-authored-by: Heitor Ramon Ribeiro <[email protected]> Co-authored-by: Marcin Kwiatkowski <[email protected]> Co-authored-by: Heitor Ramon Ribeiro <[email protected]>
1 parent 2e2dbce commit e700ed1

File tree

4 files changed

+4
-10
lines changed

4 files changed

+4
-10
lines changed

packages/composables/src/composables/useBilling/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ const factoryParams: UseBillingParams<any, any> = {
4949
: ({
5050
address: {
5151
...address,
52-
street: [address.street, apartment, neighborhood, extra],
52+
street: [address.street, apartment, neighborhood, extra].filter(Boolean),
5353
},
5454
same_as_shipping: sameAsShipping,
5555
});

packages/composables/src/composables/useShipping/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ const factoryParams: UseShippingParams<any, any> = {
4949
: ({
5050
address: {
5151
...address,
52-
street: [address.street, apartment, neighborhood, extra],
52+
street: [address.street, apartment, neighborhood, extra].filter(Boolean),
5353
},
5454
});
5555

packages/theme/pages/Checkout/UserAccount.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,7 @@ export default defineComponent({
218218
if (!isAuthenticated.value) {
219219
await (
220220
!createUserAccount.value
221-
? attachToCart({ user: form.value })
221+
? attachToCart({ email: form.value.email })
222222
: register({ user: form.value })
223223
);
224224
}

packages/theme/pages/Checkout/__tests__/UserAccount.spec.js

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -94,13 +94,7 @@ describe('<UserAccount/>', () => {
9494
await waitFor(() => {
9595
expect(attachToCartMock).toHaveBeenCalledTimes(1);
9696
expect(attachToCartMock).toHaveBeenCalledWith({
97-
user: {
98-
99-
firstname: 'James',
100-
lastname: 'Bond',
101-
password: '',
102-
is_subscribed: false,
103-
},
97+
10498
});
10599
});
106100
expect(routerPushMock).toHaveBeenCalledTimes(1);

0 commit comments

Comments
 (0)