Skip to content
This repository was archived by the owner on Jan 26, 2024. It is now read-only.

Commit 6611bb8

Browse files
authored
Merge pull request #1391 from pkarw/develop
AddToCart “disabled” class fix after removing variatns
2 parents 6564e41 + f1c8905 commit 6611bb8

File tree

3 files changed

+12
-2
lines changed

3 files changed

+12
-2
lines changed

core/store/modules/cart/index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ EventBus.$on('servercart-after-pulled', (event) => { // example stock check call
9595
for (const clientItem of clientItems) {
9696
cartHasItems = true
9797
const serverItem = serverItems.find((itm) => {
98-
return itm.sku === clientItem.sku || itm.sku.indexOf(clientItem.sku + '-') >= 0 /* bundle products */
98+
return itm.sku === clientItem.sku || itm.sku.indexOf(clientItem.sku + '-') === 0 /* bundle products */
9999
})
100100

101101
if (!serverItem) {
@@ -138,7 +138,7 @@ EventBus.$on('servercart-after-pulled', (event) => { // example stock check call
138138
for (const serverItem of serverItems) {
139139
if (serverItem) {
140140
const clientItem = clientItems.find((itm) => {
141-
return itm.sku === serverItem.sku || serverItem.sku.indexOf(itm.sku + '-') >= 0 /* bundle products */
141+
return itm.sku === serverItem.sku || serverItem.sku.indexOf(itm.sku + '-') === 0 /* bundle products */
142142
})
143143
if (!clientItem) {
144144
console.log('No client item for ' + serverItem.sku)

core/store/modules/product/helpers.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ function _filterRootProductByStockitem (context, stockItem, product, errorCallba
1919
product.errors.variants = i18n.t('No available product variants')
2020
context.state.current.errors = product.errors
2121
context.commit(types.CATALOG_SET_PRODUCT_CURRENT, product) // just override the reference to not miss changes in the configurable_children
22+
EventBus.$emit('product-after-removevariant', { product: product })
2223
if (config.products.listOutOfStockProducts === false) {
2324
errorCallback(new Error('Product query returned empty result'))
2425
}

src/themes/default/components/core/AddToCart.vue

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,18 @@ export default {
1515
directives: { focusClean },
1616
components: { ButtonFull },
1717
methods: {
18+
onAfterRemovedVariant () {
19+
this.$forceUpdate()
20+
},
1821
canBeAdded (product) {
1922
return formatProductMessages(product.errors) !== ''
2023
}
24+
},
25+
created () {
26+
this.$bus.$on('product-after-removevariant', this.onAfterRemovedVariant)
27+
},
28+
beforeDestroy () {
29+
this.$bus.$off('product-after-removevariant')
2130
}
2231
}
2332
</script>

0 commit comments

Comments
 (0)