diff --git a/CHANGELOG.md b/CHANGELOG.md index 661cdbd720..c176e5b1da 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -16,6 +16,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Fixed - Use LRU as object contructor based on newest changes in module - @gibkigonzo (#4242) +- Fixes problems related to tax calculation and price filter in multistore setup - @juho-jaakkola (#4376) ## [1.11.3] - 2020.04.27 diff --git a/core/lib/types.ts b/core/lib/types.ts index 507806fab7..ed2dc34b31 100644 --- a/core/lib/types.ts +++ b/core/lib/types.ts @@ -20,7 +20,9 @@ export interface StoreView { index: string }, tax: { - sourcePriceIncludesTax: boolean, + sourcePriceIncludesTax?: boolean, + finalPriceIncludesTax?: boolean, + deprecatedPriceFieldsSupport?: boolean, defaultCountry: string, defaultRegion: null | string, calculateServerSide: boolean, diff --git a/core/modules/catalog-next/store/category/getters.ts b/core/modules/catalog-next/store/category/getters.ts index 8b5bde50b8..57d2e79a54 100644 --- a/core/modules/catalog-next/store/category/getters.ts +++ b/core/modules/catalog-next/store/category/getters.ts @@ -14,7 +14,7 @@ import { getFiltersFromQuery } from '../../helpers/filterHelpers' import { Category } from '../../types/Category' import { parseCategoryPath } from '@vue-storefront/core/modules/breadcrumbs/helpers' import { _prepareCategoryPathIds, getSearchOptionsFromRouteParams } from '../../helpers/categoryHelpers'; -import { removeStoreCodeFromRoute } from '@vue-storefront/core/lib/multistore' +import { currentStoreView, removeStoreCodeFromRoute } from '@vue-storefront/core/lib/multistore' import cloneDeep from 'lodash-es/cloneDeep' function mapCategoryProducts (productsFromState, productsData) { @@ -77,8 +77,8 @@ const getters: GetterTree = { }); filters[attrToFilter] = filterOptions.sort(compareByLabel) } else { // special case is range filter for prices - const storeView = rootState.storeView - const currencySign = storeView.i18n.currencySign + const currencySign = currentStoreView().i18n.currencySign + if (aggregations['agg_range_' + attrToFilter]) { let index = 0 let count = aggregations['agg_range_' + attrToFilter].buckets.length diff --git a/core/modules/catalog/store/tax/actions.ts b/core/modules/catalog/store/tax/actions.ts index 8847c2fa5e..72faad3ea1 100644 --- a/core/modules/catalog/store/tax/actions.ts +++ b/core/modules/catalog/store/tax/actions.ts @@ -11,6 +11,7 @@ import config from 'config' import { calculateProductTax } from '@vue-storefront/core/modules/catalog/helpers/taxCalc' import { doPlatformPricesSync } from '@vue-storefront/core/modules/catalog/helpers' import { catalogHooksExecutors } from './../../hooks' +import { currentStoreView } from '@vue-storefront/core/lib/multistore'; const actions: ActionTree = { async list ({ state, commit, dispatch }, { entityType = 'taxrule' }) { @@ -48,6 +49,8 @@ const actions: ActionTree = { return doPlatformPricesSync(mutatedProducts) } + let storeView = currentStoreView() + const tcs = await dispatch('list', {}) const { defaultCountry, @@ -55,7 +58,7 @@ const actions: ActionTree = { sourcePriceIncludesTax, finalPriceIncludesTax, deprecatedPriceFieldsSupport - } = rootState.storeView.tax + } = storeView.tax const recalculatedProducts = mutatedProducts.map(product => calculateProductTax({ diff --git a/core/modules/catalog/store/tax/getters.ts b/core/modules/catalog/store/tax/getters.ts index 1fc26780aa..aa65d66f74 100644 --- a/core/modules/catalog/store/tax/getters.ts +++ b/core/modules/catalog/store/tax/getters.ts @@ -1,6 +1,7 @@ import { GetterTree } from 'vuex' import RootState from '@vue-storefront/core/types/RootState' import TaxState from '../../types/TaxState' +import { currentStoreView } from '@vue-storefront/core/lib/multistore'; const getters: GetterTree = { getRules: (state) => state.rules, @@ -17,7 +18,7 @@ const getters: GetterTree = { return currentUser.group_id }, getIsUserGroupedTaxActive: (state, getters, rootState) => { - return typeof rootState.storeView.tax.userGroupId === 'number' + return typeof currentStoreView().tax.userGroupId === 'number' } }