From 900c358ddd1127bbb9a694b2007b231da45ad8ae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexander=20H=C3=A4lbich?= Date: Mon, 16 Mar 2020 12:31:35 +0100 Subject: [PATCH] Fix calculation of cart/isVirtualCart for an empty cart --- CHANGELOG.md | 1 + core/modules/cart/store/getters.ts | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 793030595d..4ceaeedb45 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -39,6 +39,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - `getVariantWithLowestPrice` uses inexistent `final_price` property - @cewald (#4091) - Fixed `NOT_ALLOWED_SSR_EXTENSIONS_REGEX` to only match with file extensions having a dot - @haelbichalex (#4100) - Fixed problem with not showing error message when placing an order fails - @qiqqq +- Fixed `cart/isVirtualCart` to return `false` when cart is empty - @haelbichalex(#4182) ### Changed / Improved diff --git a/core/modules/cart/store/getters.ts b/core/modules/cart/store/getters.ts index d881571477..523381646f 100644 --- a/core/modules/cart/store/getters.ts +++ b/core/modules/cart/store/getters.ts @@ -30,7 +30,7 @@ const getters: GetterTree = { getItemsTotalQuantity: ({ cartItems }) => config.cart.minicartCountType === 'items' ? cartItems.length : sumBy(cartItems, p => p.qty), getCoupon: ({ platformTotals }): AppliedCoupon | false => !(platformTotals && platformTotals.hasOwnProperty('coupon_code')) ? false : { code: platformTotals.coupon_code, discount: platformTotals.discount_amount }, - isVirtualCart: ({ cartItems }) => cartItems.every(itm => itm.type_id === 'downloadable' || itm.type_id === 'virtual'), + isVirtualCart: ({ cartItems }) => cartItems.length ? cartItems.every(itm => itm.type_id === 'downloadable' || itm.type_id === 'virtual') : false, canUpdateMethods: (state, getters) => getters.isCartSyncEnabled && getters.isCartConnected, canSyncTotals: (state, getters) => getters.isTotalsSyncEnabled && getters.isCartConnected, isCartEmpty: state => state.cartItems.length === 0,