@wikala/spmkt 2.28.3 → 2.29.1
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.
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<div>
|
|
3
|
-
<div
|
|
4
|
-
<div
|
|
3
|
+
<div class="pc-label">{{ $t('cart.haveACoupon') }}</div>
|
|
4
|
+
<div class="pc-input" :class="{ 'mb-4': cart.discount }">
|
|
5
5
|
<input @keyup.enter="applyCoupon" v-model="couponCode" class="input" type="text" name="coupon_code" :placeholder="$t('cart.enterCouponPlaceholder')" />
|
|
6
6
|
<button name="enter_coupon" @click="applyCoupon" class="button is-small" :class="{ 'is-loading': acLoading }">{{ $t('cart.applyCoupon') }}</button>
|
|
7
7
|
</div>
|
|
8
8
|
<div v-if="cart.discount">
|
|
9
9
|
<div class="applied-discounts has-text-weight-bold">
|
|
10
|
-
<div class="has-text-success">{{ $t('cart.discountApplied') }}</div>
|
|
10
|
+
<div class="has-text-success">{{ $t('cart.discountApplied') }} [{{ cart.coupon_code }}]</div>
|
|
11
11
|
<div v-if="cart.items.length === 1 || cart.discount === cart.order_discount" class="has-text-success">
|
|
12
12
|
{{ $t('cart.youSaved') }} {{ formatMoney(cart.discount, { precision: 2 }) }}!
|
|
13
13
|
</div>
|
|
@@ -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)
|
|
@@ -258,6 +263,34 @@ 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
|
+
|
|
283
|
+
if(variantDiscountInfo) {
|
|
284
|
+
discountInfoContainer.classList.remove('is-hidden')
|
|
285
|
+
if(variantDiscountInfo.coupon_applied) {
|
|
286
|
+
discountMessageContainer.textContent = `U korpi će vam biti obračunat popust od ${this.formatMoney(variantDiscountInfo.discount_amount)} RSD`
|
|
287
|
+
} else {
|
|
288
|
+
discountMessageContainer.textContent = `Iskoristi promo kod ${variantDiscountInfo.coupon_code} za popust od ${this.formatMoney(variantDiscountInfo.discount_amount)} RSD`
|
|
289
|
+
}
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
},
|
|
293
|
+
|
|
261
294
|
getVariantByOption(optionId, optionValue) {
|
|
262
295
|
if (this.productVariantOptions.length !== 1) {
|
|
263
296
|
return {}
|
|
@@ -342,6 +375,7 @@ export default {
|
|
|
342
375
|
this.$bus.$emit('updatePrice', this.selectedVariant.price, this.selectedVariant.compare_price)
|
|
343
376
|
}
|
|
344
377
|
this.updateOverridePriceNotification()
|
|
378
|
+
this.updateDiscountInfo()
|
|
345
379
|
}
|
|
346
380
|
},
|
|
347
381
|
|