@ecomplus/storefront-components 1.0.0-beta.180 → 1.0.0-beta.181
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.
- package/CHANGELOG.md +7 -0
- package/dist/storefront-components.min.js +1 -1
- package/dist/storefront-components.min.js.map +1 -1
- package/package.json +1 -1
- package/src/html/ShippingCalculator.html +2 -1
- package/src/js/CartQuickview.js +1 -1
- package/src/js/DiscountApplier.js +37 -10
- package/src/js/ShippingCalculator.js +2 -0
package/package.json
CHANGED
|
@@ -55,7 +55,8 @@
|
|
|
55
55
|
leave-active-class="animated fadeOutDown"
|
|
56
56
|
>
|
|
57
57
|
<div
|
|
58
|
-
v-if="canSelectServices && !canAutoSelectService &&
|
|
58
|
+
v-if="canSelectServices && !canAutoSelectService &&
|
|
59
|
+
selectedService === null && shippingServices.length"
|
|
59
60
|
class="shipping-calculator__label"
|
|
60
61
|
>
|
|
61
62
|
<i class="i-arrow-down animated wobble"></i>
|
package/src/js/CartQuickview.js
CHANGED
|
@@ -80,6 +80,7 @@ export default {
|
|
|
80
80
|
default: true
|
|
81
81
|
},
|
|
82
82
|
modulesPayload: Object,
|
|
83
|
+
paymentGateway: Object,
|
|
83
84
|
ecomCart: {
|
|
84
85
|
type: Object,
|
|
85
86
|
default () {
|
|
@@ -125,6 +126,22 @@ export default {
|
|
|
125
126
|
canAddCoupon () {
|
|
126
127
|
return !this.couponCode || !this.isCouponApplied ||
|
|
127
128
|
this.couponCode !== this.localCouponCode
|
|
129
|
+
},
|
|
130
|
+
|
|
131
|
+
paymentGatewayDiscount () {
|
|
132
|
+
if (!this.paymentGateway) return 0
|
|
133
|
+
const { discount } = this.paymentGateway
|
|
134
|
+
if (!discount || !discount.value) return 0
|
|
135
|
+
const applyAt = discount.apply_at || 'total'
|
|
136
|
+
const maxDiscount = applyAt === 'total' ? this.localAmountTotal : this.amount[applyAt]
|
|
137
|
+
if (maxDiscount > 0) {
|
|
138
|
+
const { type, value } = discount
|
|
139
|
+
if (type === 'percentage') {
|
|
140
|
+
return maxDiscount * value / 100
|
|
141
|
+
}
|
|
142
|
+
return value <= maxDiscount ? value : maxDiscount
|
|
143
|
+
}
|
|
144
|
+
return 0
|
|
128
145
|
}
|
|
129
146
|
},
|
|
130
147
|
|
|
@@ -133,7 +150,8 @@ export default {
|
|
|
133
150
|
const amount = this.amount || {
|
|
134
151
|
subtotal: this.ecomCart.data.subtotal
|
|
135
152
|
}
|
|
136
|
-
this.localAmountTotal = (amount.subtotal || 0) +
|
|
153
|
+
this.localAmountTotal = (amount.subtotal || 0) +
|
|
154
|
+
(amount.freight || 0) - this.paymentGatewayDiscount
|
|
137
155
|
},
|
|
138
156
|
|
|
139
157
|
parseDiscountOptions (listResult = []) {
|
|
@@ -230,7 +248,7 @@ export default {
|
|
|
230
248
|
subtotal: this.localAmountTotal,
|
|
231
249
|
...this.amount,
|
|
232
250
|
total: this.localAmountTotal,
|
|
233
|
-
discount:
|
|
251
|
+
discount: this.paymentGatewayDiscount
|
|
234
252
|
},
|
|
235
253
|
items: this.ecomCart.data.items,
|
|
236
254
|
...data
|
|
@@ -268,6 +286,17 @@ export default {
|
|
|
268
286
|
) {
|
|
269
287
|
this.fetchDiscountOptions()
|
|
270
288
|
}
|
|
289
|
+
},
|
|
290
|
+
|
|
291
|
+
scheduleUpdateDiscount () {
|
|
292
|
+
if (this.isUpdateSheduled) return
|
|
293
|
+
this.isUpdateSheduled = true
|
|
294
|
+
this.$nextTick(() => {
|
|
295
|
+
setTimeout(() => {
|
|
296
|
+
this.updateDiscount()
|
|
297
|
+
this.isUpdateSheduled = false
|
|
298
|
+
}, 600)
|
|
299
|
+
})
|
|
271
300
|
}
|
|
272
301
|
},
|
|
273
302
|
|
|
@@ -296,14 +325,8 @@ export default {
|
|
|
296
325
|
},
|
|
297
326
|
|
|
298
327
|
localAmountTotal (total, oldTotal) {
|
|
299
|
-
if (oldTotal !== null && Math.abs(total - oldTotal) > 0.01
|
|
300
|
-
this.
|
|
301
|
-
this.$nextTick(() => {
|
|
302
|
-
setTimeout(() => {
|
|
303
|
-
this.updateDiscount()
|
|
304
|
-
this.isUpdateSheduled = false
|
|
305
|
-
}, 600)
|
|
306
|
-
})
|
|
328
|
+
if (oldTotal !== null && Math.abs(total - oldTotal) > 0.01) {
|
|
329
|
+
this.scheduleUpdateDiscount()
|
|
307
330
|
}
|
|
308
331
|
},
|
|
309
332
|
|
|
@@ -312,6 +335,10 @@ export default {
|
|
|
312
335
|
this.fixAmount()
|
|
313
336
|
},
|
|
314
337
|
deep: true
|
|
338
|
+
},
|
|
339
|
+
|
|
340
|
+
paymentGatewayDiscount () {
|
|
341
|
+
this.scheduleUpdateDiscount()
|
|
315
342
|
}
|
|
316
343
|
},
|
|
317
344
|
|
|
@@ -208,6 +208,8 @@ export default {
|
|
|
208
208
|
})
|
|
209
209
|
if (this.canAutoSelectService) {
|
|
210
210
|
this.setSelectedService(0)
|
|
211
|
+
} else {
|
|
212
|
+
this.selectedService = null
|
|
211
213
|
}
|
|
212
214
|
this.hasPaidOption = Boolean(this.shippingServices.find(service => {
|
|
213
215
|
return service.shipping_line.total_price || service.shipping_line.price
|