@ecomplus/storefront-components 1.0.0-beta.182 → 1.0.0-beta.184

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ecomplus/storefront-components",
3
- "version": "1.0.0-beta.182",
3
+ "version": "1.0.0-beta.184",
4
4
  "description": "Vue components for E-Com Plus Storefront",
5
5
  "main": "dist/storefront-components.min.js",
6
6
  "scripts": {
@@ -33,7 +33,7 @@
33
33
  },
34
34
  "dependencies": {
35
35
  "@brazilian-utils/brazilian-utils": "^1.0.0-rc.12",
36
- "@ecomplus/client": "^2.3.1",
36
+ "@ecomplus/client": "^2.4.0",
37
37
  "@ecomplus/i18n": "^1.32.2",
38
38
  "@ecomplus/passport-client": "^1.2.1",
39
39
  "@ecomplus/search-engine": "^2.6.1",
@@ -156,6 +156,7 @@ export default {
156
156
 
157
157
  parseDiscountOptions (listResult = []) {
158
158
  let extraDiscountValue = 0
159
+ let hasFreebies = false
159
160
  if (listResult.length) {
160
161
  let discountRule, invalidCouponMsg, invalidAlertVariant
161
162
  listResult.forEach(appResult => {
@@ -193,7 +194,14 @@ export default {
193
194
  invalidCouponMsg = response.invalid_coupon_message
194
195
  }
195
196
  if (this.canAddFreebieItems) {
196
- addFreebieItems(this.ecomCart, response.freebie_product_ids)
197
+ const freebieProductIds = response.freebie_product_ids
198
+ if (Array.isArray(freebieProductIds) && freebieProductIds.length) {
199
+ hasFreebies = true
200
+ addFreebieItems(this.ecomCart, freebieProductIds)
201
+ if (this.localCouponCode) {
202
+ this.$emit('update:coupon-code', this.localCouponCode)
203
+ }
204
+ }
197
205
  }
198
206
  }
199
207
  })
@@ -213,7 +221,7 @@ export default {
213
221
  }
214
222
  this.$emit('set-discount-rule', discountRule)
215
223
  } else {
216
- if (this.localCouponCode) {
224
+ if (this.localCouponCode && !hasFreebies) {
217
225
  this.alertText = invalidCouponMsg || this.i19invalidCouponMsg
218
226
  this.alertVariant = invalidAlertVariant || 'warning'
219
227
  } else {