diff --git a/CHANGELOG.md b/CHANGELOG.md index b139855969..b99469bfca 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -21,6 +21,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Update `hasProductErrors` in Product component and support additional sku in custom options - @gibkigonzo (#3976) - Fixed Stock logic not working with manage_stock set to false - @andrzejewsky - (#3957) - Support old price format in `ProductPrice` - @gibkigonzo (#3978) +- Fixed product bundle comparison condition - @gk-daniel (#4004) ## [1.11.0] - 2019.12.20 diff --git a/core/modules/cart/helpers/productsEquals.ts b/core/modules/cart/helpers/productsEquals.ts index f87019d4ff..69156aee04 100644 --- a/core/modules/cart/helpers/productsEquals.ts +++ b/core/modules/cart/helpers/productsEquals.ts @@ -36,7 +36,9 @@ const productsEquals = (product1: CartItem, product2: CartItem): boolean => { const typeProduct2 = getProductType(product2) if (typeProduct1 === 'bundle' || typeProduct2 === 'bundle') { - return isServerIdsEquals(product1, product2) || isChecksumEquals(product1, product2) + if (isServerIdsEquals(product1, product2) || isChecksumEquals(product1, product2)) { + return true + } } return isServerIdsEquals(product1, product2) || String(product1.sku) === String(product2.sku) diff --git a/core/modules/cart/test/unit/helpers/productEquals.spec.ts b/core/modules/cart/test/unit/helpers/productEquals.spec.ts index d7612a0735..bb9fe4eab2 100644 --- a/core/modules/cart/test/unit/helpers/productEquals.spec.ts +++ b/core/modules/cart/test/unit/helpers/productEquals.spec.ts @@ -64,12 +64,12 @@ describe('Cart productEquals', () => { expect(productsEquals(product1, product2)).toBeTruthy() }); - - it('returns false because bundle products have not the same options selected', async () => { + + it('returns true because bundle products have not the same options selected', async () => { const product1 = createBundleProduct({ id: 1, sku: 'WG-001', type_id: 'bundle', options: [2, 2, 5, 8] }) const product2 = createBundleProduct({ id: 2, sku: 'WG-001', type_id: 'bundle', options: [2, 4, 5, 8] }) - expect(productsEquals(product1, product2)).toBeFalsy() + expect(productsEquals(product1, product2)).toBeTruthy() }); it('returns true because bundle products have the same server id', async () => { @@ -79,7 +79,7 @@ describe('Cart productEquals', () => { expect(productsEquals(product1, product2)).toBeTruthy() }); - it('returns true because configurable products have the same eku', async () => { + it('returns true because configurable products have the same sku', async () => { const product1 = createConfigurableProduct({ id: 1, sku: 'WG-001' }) const product2 = createConfigurableProduct({ id: 2, sku: 'WG-001' })