@wikala/spmkt 2.18.1 → 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,7 +170,7 @@ 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
176
  this.updateDiscountBadge()
@@ -214,13 +214,16 @@ export default {
214
214
  },
215
215
 
216
216
  updateDiscountBadge() {
217
- let discountPercent = Math.round((this.selectedVariant.compare_price - this.selectedVariant.price)/this.selectedVariant.compare_price * 100, 0)
218
217
  let badge = document.querySelector('.product-main .badge-discount')
219
218
  if(!badge) {
220
219
  return
221
220
  }
222
- //console.log('setting bagde-discount', -discountPercent+'%')
223
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
+
224
227
  if(discountPercent > 0) {
225
228
  badge.style.visibility = 'visible';
226
229
  badge.textContent = `-${discountPercent}%`
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wikala/spmkt",
3
- "version": "2.18.1",
3
+ "version": "2.18.2",
4
4
  "private": false,
5
5
  "description": "supermarket",
6
6
  "scripts": {