@wikala/spmkt 2.28.3 → 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)
@@ -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 {}
@@ -342,6 +382,7 @@ export default {
342
382
  this.$bus.$emit('updatePrice', this.selectedVariant.price, this.selectedVariant.compare_price)
343
383
  }
344
384
  this.updateOverridePriceNotification()
385
+ this.updateDiscountInfo()
345
386
  }
346
387
  },
347
388
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wikala/spmkt",
3
- "version": "2.28.3",
3
+ "version": "2.29.0",
4
4
  "private": false,
5
5
  "description": "supermarket",
6
6
  "scripts": {