-
Notifications
You must be signed in to change notification settings - Fork 10
Conversation
This change would handle the case in which your Multistore doesn't use the storeCode in the URL for the main store.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To get the right storeCode we should use import {currentStoreView} from '@vue-storefront/core/lib/multistore'
and from that currentStoreView().storeCode
to get the storeCode from the current store.
router/beforeEach.ts
Outdated
@@ -15,6 +16,8 @@ export function beforeEach (to: Route, from: Route, next) { | |||
if (multistoreEnabled) { | |||
if (storeCode in stores && to.name === storeCode + '-checkout') { | |||
window.location.replace(stores[storeCode].cmsUrl + '/vue/cart/sync/token/' + userToken + '/cart/' + cartToken) | |||
} else if (to.name === 'checkout') { | |||
window.location.replace(stores[config.defaultStoreCode].cmsUrl + '/vue/cart/sync/token/' + userToken + '/cart/' + cartToken) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
} else if (storeCode in stores && to.name === 'checkout' && stores[storeCode].cmsUrl !== undefined) {
window.location.replace(stores[storeCode].cmsUrl + '/vue/cart/sync/token/' + userToken + '/cart/' + cartToken)
}
Isn't that the right code we would need here ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In my case your if condition still wouldn't work because of the to.name === 'checkout'
but I guess you could use currentStoreView().storeCode
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That i don't really understand?
You are doing the to.name === 'checkout'
too or are you meaning something else that would not work for you?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, you're right.
I meant the if (storeCode in stores
part. This doesn't work because of const storeCode = storeCodeFromRoute(to)
.
In my case there is no storeCode in the url of the main store.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That is why the const storeCode = storeCodeFromRoute(to)
should be replaced with const storeCode = currentStoreView().storeCode
then you have your storeCode.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see it now. I'm gonna try to commit this in my PR branch.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've commited your solution to the branch.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tanks for the fix.
Now we only need to wait until one finds the time to merge this.
Yes this does fix the issue #13. |
This change would handle the case in which your Multistore doesn't use the storeCode in the URL for the main store.