@wikala/spmkt 2.28.1 → 2.28.3

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.
@@ -61,6 +61,14 @@ export default {
61
61
  },
62
62
  variantId: {
63
63
  type: Number
64
+ },
65
+ badgeSelector: {
66
+ type: String,
67
+ default: '.product-in-stock .discount.badge'
68
+ },
69
+ overridePriceNotificationSelector: {
70
+ type: String,
71
+ default: '.override-price-active'
64
72
  }
65
73
  },
66
74
 
@@ -210,12 +218,12 @@ export default {
210
218
  this.updateDiscountBadge(variant)
211
219
 
212
220
  this.$nextTick(() => {
213
- this.emitEvents()
221
+ this.emitEvents('preselect')
214
222
  })
215
223
  },
216
224
 
217
225
  updateDiscountBadge() {
218
- let badge = document.querySelector('.product-main .badge-discount')
226
+ let badge = document.querySelector(this.badgeSelector)
219
227
  if(!badge) {
220
228
  return
221
229
  }
@@ -232,18 +240,21 @@ export default {
232
240
  },
233
241
 
234
242
  updateOverridePriceNotification() {
235
- let opActiveContainer = document.querySelector('.override-price-active')
243
+ let opActiveContainer = document.querySelector(this.overridePriceNotificationSelector)
236
244
  if(!opActiveContainer) {
237
245
  return
238
246
  }
239
247
  opActiveContainer.textContent = ''
240
-
248
+
241
249
  if(!this.selectedVariant) {
242
250
  return
243
251
  }
244
252
 
245
253
  if(this.selectedVariant.override_price_active) {
246
- opActiveContainer.textContent = 'Trajanje akcije od ' + formatDate(new Date(this.selectedVariant.override_start_at), 'DD.MM.YYYY HH:mm') + ' do ' + formatDate(new Date(this.selectedVariant.override_stop_at), 'DD.MM.YYYY HH:mm')
254
+ opActiveContainer.textContent = 'Trajanje akcije od ' +
255
+ formatDate(new Date(this.selectedVariant.override_start_at), 'DD.MM.YYYY HH:mm') +
256
+ ' do ' +
257
+ formatDate(new Date(this.selectedVariant.override_stop_at), 'DD.MM.YYYY HH:mm')
247
258
  }
248
259
  },
249
260
 
@@ -317,7 +328,7 @@ export default {
317
328
 
318
329
  },
319
330
 
320
- emitEvents() {
331
+ emitEvents(context='') {
321
332
  if (!this.selectedVariant) {
322
333
  this.$bus.$emit('selectVariant', false)
323
334
  this.$bus.$emit('updateSKU', '')
@@ -325,9 +336,11 @@ export default {
325
336
  }
326
337
 
327
338
  this.$bus.$emit('selectVariant', this.selectedVariant.id)
328
- this.$bus.$emit('updatePrice', this.selectedVariant.price, this.selectedVariant.compare_price)
329
339
  this.$bus.$emit('changePhoto', this.selectedVariant.default_image_id)
330
340
  this.$bus.$emit('updateSKU', this.selectedVariant.sku || this.selectedVariant.id)
341
+ if(context !== 'preselect') {
342
+ this.$bus.$emit('updatePrice', this.selectedVariant.price, this.selectedVariant.compare_price)
343
+ }
331
344
  this.updateOverridePriceNotification()
332
345
  }
333
346
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wikala/spmkt",
3
- "version": "2.28.1",
3
+ "version": "2.28.3",
4
4
  "private": false,
5
5
  "description": "supermarket",
6
6
  "scripts": {