@wikala/spmkt 2.28.2 → 2.29.0
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.
|
@@ -69,6 +69,10 @@ export default {
|
|
|
69
69
|
overridePriceNotificationSelector: {
|
|
70
70
|
type: String,
|
|
71
71
|
default: '.override-price-active'
|
|
72
|
+
},
|
|
73
|
+
discountInfoSelector: {
|
|
74
|
+
type: String,
|
|
75
|
+
default: '.discount-notice'
|
|
72
76
|
}
|
|
73
77
|
},
|
|
74
78
|
|
|
@@ -210,6 +214,7 @@ export default {
|
|
|
210
214
|
if(!variant) {
|
|
211
215
|
return
|
|
212
216
|
}
|
|
217
|
+
console.log('preselecting variant', variant)
|
|
213
218
|
this.selectedVariant = variant
|
|
214
219
|
this.selectedVariant.options.forEach((vo) => {
|
|
215
220
|
this.$set(this.selectedOptions, vo.attribute_id, vo.value)
|
|
@@ -218,7 +223,7 @@ export default {
|
|
|
218
223
|
this.updateDiscountBadge(variant)
|
|
219
224
|
|
|
220
225
|
this.$nextTick(() => {
|
|
221
|
-
this.emitEvents()
|
|
226
|
+
this.emitEvents('preselect')
|
|
222
227
|
})
|
|
223
228
|
},
|
|
224
229
|
|
|
@@ -258,6 +263,41 @@ export default {
|
|
|
258
263
|
}
|
|
259
264
|
},
|
|
260
265
|
|
|
266
|
+
updateDiscountInfo() {
|
|
267
|
+
let discountInfoContainer = document.querySelector(this.discountInfoSelector)
|
|
268
|
+
let discountMessageContainer = discountInfoContainer.querySelector('.discount-message')
|
|
269
|
+
if(!discountInfoContainer) {
|
|
270
|
+
return
|
|
271
|
+
}
|
|
272
|
+
discountInfoContainer.classList.add('is-hidden')
|
|
273
|
+
discountMessageContainer.textContent = ''
|
|
274
|
+
|
|
275
|
+
if(!this.selectedVariant) {
|
|
276
|
+
return
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
const productDiscountInfo = window.wkl_product_discount_info
|
|
280
|
+
|
|
281
|
+
const variantDiscountInfo = productDiscountInfo.find(pdi => pdi.product_id == this.selectedVariant.id)
|
|
282
|
+
console.log('variantDiscountInfo', variantDiscountInfo)
|
|
283
|
+
/*
|
|
284
|
+
@if($discountItem['coupon_applied'])
|
|
285
|
+
U korpi će vam biti obračunat popust od {{ fmt_money($discountItem['discount_amount']) }} RSD
|
|
286
|
+
@else
|
|
287
|
+
Iskoristi promo kod {!! $discountItem['coupon_code'] !!} za popust od {{ fmt_money($discountItem['discount_amount']) }} RSD
|
|
288
|
+
@endif
|
|
289
|
+
*/
|
|
290
|
+
if(variantDiscountInfo) {
|
|
291
|
+
discountInfoContainer.classList.remove('is-hidden')
|
|
292
|
+
if(variantDiscountInfo.coupon_applied) {
|
|
293
|
+
discountMessageContainer.textContent = `U korpi će vam biti obračunat popust od ${this.formatMoney(variantDiscountInfo.discount_amount)} RSD`
|
|
294
|
+
} else {
|
|
295
|
+
discountMessageContainer.textContent = `Iskoristi promo kod ${variantDiscountInfo.coupon_code} za popust od ${this.formatMoney(variantDiscountInfo.discount_amount)} RSD`
|
|
296
|
+
}
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
},
|
|
300
|
+
|
|
261
301
|
getVariantByOption(optionId, optionValue) {
|
|
262
302
|
if (this.productVariantOptions.length !== 1) {
|
|
263
303
|
return {}
|
|
@@ -328,7 +368,7 @@ export default {
|
|
|
328
368
|
|
|
329
369
|
},
|
|
330
370
|
|
|
331
|
-
emitEvents() {
|
|
371
|
+
emitEvents(context='') {
|
|
332
372
|
if (!this.selectedVariant) {
|
|
333
373
|
this.$bus.$emit('selectVariant', false)
|
|
334
374
|
this.$bus.$emit('updateSKU', '')
|
|
@@ -336,10 +376,13 @@ export default {
|
|
|
336
376
|
}
|
|
337
377
|
|
|
338
378
|
this.$bus.$emit('selectVariant', this.selectedVariant.id)
|
|
339
|
-
this.$bus.$emit('updatePrice', this.selectedVariant.price, this.selectedVariant.compare_price)
|
|
340
379
|
this.$bus.$emit('changePhoto', this.selectedVariant.default_image_id)
|
|
341
380
|
this.$bus.$emit('updateSKU', this.selectedVariant.sku || this.selectedVariant.id)
|
|
381
|
+
if(context !== 'preselect') {
|
|
382
|
+
this.$bus.$emit('updatePrice', this.selectedVariant.price, this.selectedVariant.compare_price)
|
|
383
|
+
}
|
|
342
384
|
this.updateOverridePriceNotification()
|
|
385
|
+
this.updateDiscountInfo()
|
|
343
386
|
}
|
|
344
387
|
},
|
|
345
388
|
|