Skip to content

Commit

Permalink
Merge pull request vuestorefront#1764 from pkarw/develop
Browse files Browse the repository at this point in the history
  • Loading branch information
pkarw authored Sep 25, 2018
2 parents 8d253fc + 9823b6f commit f9a9ddc
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 4 deletions.
1 change: 1 addition & 0 deletions config/default.json
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@
}
},
"cart": {
"bypassCartLoaderForAuthorizedUsers": true,
"multisiteCommonCart": true,
"server_merge_by_default": true,
"synchronize": true,
Expand Down
5 changes: 1 addition & 4 deletions core/store/modules/cart/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -111,9 +111,6 @@ const actions: ActionTree<CartState, RootState> = {
serverCreate (context, { guestCart = false }) {
if (rootStore.state.config.cart.synchronize && !Vue.prototype.$isServer) {
if ((Date.now() - context.state.cartServerCreatedAt) >= CART_CREATE_INTERVAL_MS) {
if (guestCart) {
Vue.prototype.$db.usersCollection.setItem('last-cart-bypass-ts', new Date().getTime())
}
const task = { url: guestCart ? rootStore.state.config.cart.create_endpoint.replace('{{token}}', '') : rootStore.state.config.cart.create_endpoint, // sync the cart
payload: {
method: 'POST',
Expand Down Expand Up @@ -467,7 +464,7 @@ const actions: ActionTree<CartState, RootState> = {
if (err) {
console.error(err)
}
if ((Date.now() - lastCartBypassTs) >= (1000 * 60 * 24)) { // don't refresh the shopping cart id up to 24h after last order
if (!rootStore.state.config.cart.bypassCartLoaderForAuthorizedUsers || (Date.now() - lastCartBypassTs) >= (1000 * 60 * 24)) { // don't refresh the shopping cart id up to 24h after last order
rootStore.dispatch('cart/serverCreate', { guestCart: false }, { root: true })
}
})
Expand Down
1 change: 1 addition & 0 deletions core/store/modules/checkout/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ const actions: ActionTree<CheckoutState, RootState> = {
placeOrder (context, { order }) {
try {
context.dispatch('order/placeOrder', order, {root: true}).then(result => {
Vue.prototype.$db.usersCollection.setItem('last-cart-bypass-ts', new Date().getTime())
context.dispatch('cart/clear', {}, {root: true})
if (context.state.personalDetails.createAccount) {
context.commit(types.CHECKOUT_DROP_PASSWORD)
Expand Down

0 comments on commit f9a9ddc

Please sign in to comment.