Skip to content
This repository has been archived by the owner on Apr 11, 2024. It is now read-only.

Multistore - no storeCode in URL #14

Merged
merged 2 commits into from
Jul 5, 2019
Merged

Multistore - no storeCode in URL #14

merged 2 commits into from
Jul 5, 2019

Conversation

jpetar
Copy link
Contributor

@jpetar jpetar commented Jul 4, 2019

This change would handle the case in which your Multistore doesn't use the storeCode in the URL for the main store.

This change would handle the case in which your Multistore doesn't use the storeCode in the URL for the main store.
Copy link

@ResuBaka ResuBaka left a 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.

@@ -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)
Copy link

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 ?

Copy link
Contributor Author

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.

Copy link

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?

Copy link
Contributor Author

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.

Copy link

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.

Copy link
Contributor Author

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.

Copy link
Contributor Author

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.

Copy link

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.

@Tjitse-E
Copy link
Member

Tjitse-E commented Jul 5, 2019

@ResuBaka does this fix your issue #13?

@ResuBaka
Copy link

ResuBaka commented Jul 5, 2019

Yes this does fix the issue #13.

@Tjitse-E Tjitse-E merged commit f420d56 into Vendic:master Jul 5, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants