File tree Expand file tree Collapse file tree 2 files changed +14
-4
lines changed
core/modules/cart/helpers Expand file tree Collapse file tree 2 files changed +14
-4
lines changed Original file line number Diff line number Diff line change @@ -39,6 +39,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
39
39
- servercart-after-diff event payload - Fifciu (#5365 )
40
40
- Fix Original Price Calculation typo - @akucharczyk / @lukaszjedrasik (#5472 )
41
41
- Purge loader works properly with dynamic config reload - @Fifciu
42
+ - Multi-tab cart-sync in multi-store environment - @cewald (#5711 , #5732 )
42
43
43
44
### Changed / Improved
44
45
Original file line number Diff line number Diff line change 1
- import rootStore from '@vue-storefront/core/store' ;
1
+ import rootStore from '@vue-storefront/core/store'
2
+ import { storeViews } from 'config'
3
+ import { currentStoreView } from '@vue-storefront/core/lib/multistore'
4
+
5
+ function checkMultistoreKey ( key : string , path : string ) : boolean {
6
+ const { multistore, commonCache } = storeViews
7
+ if ( ! multistore || ( multistore && commonCache ) ) return key === path
8
+ return key === `${ currentStoreView ( ) . storeCode } -${ path } `
9
+ }
2
10
3
11
function getItemsFromStorage ( { key } ) {
4
- const value = JSON . parse ( localStorage [ key ] )
5
- if ( key === 'shop/cart/current-cart' ) {
12
+ if ( checkMultistoreKey ( key , 'shop/cart/current-cart' ) ) {
13
+ const value = JSON . parse ( localStorage [ key ] )
6
14
rootStore . dispatch ( 'cart/updateCart' , { items : value } )
7
- } else if ( key === 'shop/cart/current-totals' ) {
15
+ } else if ( checkMultistoreKey ( key , 'shop/cart/current-totals' ) ) {
16
+ const value = JSON . parse ( localStorage [ key ] )
8
17
rootStore . dispatch ( 'cart/updateTotals' , value )
9
18
}
10
19
}
You can’t perform that action at this time.
0 commit comments