@wikala/spmkt 2.18.0 → 2.18.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -170,9 +170,10 @@ export default {
|
|
|
170
170
|
},
|
|
171
171
|
|
|
172
172
|
optionSelect(optionValue, option) {
|
|
173
|
-
//console.log('opt select')
|
|
173
|
+
//console.log('opt select')this.updateDiscountBadge()
|
|
174
174
|
this.selectedVariant = null
|
|
175
175
|
this.fittingUnselected = []
|
|
176
|
+
this.updateDiscountBadge()
|
|
176
177
|
if (this.selectedOptions[option.id] === optionValue) {
|
|
177
178
|
this.$delete(this.selectedOptions, option.id)
|
|
178
179
|
} else {
|
|
@@ -213,13 +214,16 @@ export default {
|
|
|
213
214
|
},
|
|
214
215
|
|
|
215
216
|
updateDiscountBadge() {
|
|
216
|
-
let discountPercent = Math.round((this.selectedVariant.compare_price - this.selectedVariant.price)/this.selectedVariant.compare_price * 100, 0)
|
|
217
217
|
let badge = document.querySelector('.product-main .badge-discount')
|
|
218
218
|
if(!badge) {
|
|
219
219
|
return
|
|
220
220
|
}
|
|
221
|
-
//console.log('setting bagde-discount', -discountPercent+'%')
|
|
222
221
|
badge.style.visibility = 'hidden';
|
|
222
|
+
if(!this.selectedVariant) {
|
|
223
|
+
return
|
|
224
|
+
}
|
|
225
|
+
let discountPercent = Math.round((this.selectedVariant.compare_price - this.selectedVariant.price)/this.selectedVariant.compare_price * 100, 0)
|
|
226
|
+
|
|
223
227
|
if(discountPercent > 0) {
|
|
224
228
|
badge.style.visibility = 'visible';
|
|
225
229
|
badge.textContent = `-${discountPercent}%`
|