-
Notifications
You must be signed in to change notification settings - Fork 24
Thank You page redirect #7
Comments
@pkarw is it done? |
I'm not sure, didn't have a chance to test it yet |
It's partially done. What You need to add - is to expose the special ThankYouPage url in the vue-storefornt (adding it as a theme route or extension route) and in the component which is processing this route please add: rootStore.dispatch('cart/clear', {}, { root: true })
rootStore.dispatch('cart/serverCreate', { guestCart: false }, { root: true }) in the |
@pkarw , i've tried a custom route with the following component:
But this doesn't seem to work reliably. Any ideas on why the cart isn't cleared? Ik can see that By the way |
It may be the case that the cart is loaded after that ... :) I mean - beforeMount is called before cart is being loaded. Please try this method instead: global.$VS.db.cartsCollection.setItem('current-cart-token', '').catch((reason) => {
console.error(reason)
})
global.$VS.db.cartsCollection.setItem('current-cart', null).catch((reason) => {
console.error(reason) // it doesn't work on SSR
}) // populate cache |
@pkarw thanks for your suggestion! The approach suggested in your last comment works if you refresh a few times, but not if you're being redirected from Magento 2 to VS. Does this make any sense to you? |
OK :) Last suggestion that comes to my mind: mounted () {
this.$bus.$on('cart-after-loaded', (payload) => {
rootStore.dispatch('cart/clear', {}, { root: true })
})
}, |
Until we have a better/cleaner solution we're now using this:
|
Please create a PR from it! |
I did it simpler, but disabling some cart feature which behave kinda weird (in my opinion is just broken / not well made / logic is too optimistic) My solution:
mounted () {
this.$store.dispatch('cart/clear', {}, { root: true })
} It will unconditionaly clear the cart right after entering the success page. |
We need to add the configurable URL in module config where the user will be redirected after placing an Magento Order. It will be used to redirect back to Vue Storefront to clear the VS cart. Because it's not cleared after placing an order it's possible to use the same cart id second time - and get the nasty error instead #4 :)
The text was updated successfully, but these errors were encountered: