@wikala/spmkt 2.31.0 → 3.0.0-beta.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.
- package/MIGRATION_GUIDE.md +261 -0
- package/api/product.js +1 -0
- package/api/request.js +9 -4
- package/api/user.js +1 -1
- package/components/Account/AccountDashboard.vue +101 -101
- package/components/Account/AccountStore.js +57 -31
- package/components/Account/AffiliateReport.vue +56 -60
- package/components/Account/{OrderDetail.vue → Orders/OrderDetail.vue} +44 -30
- package/components/Account/Orders/Orders.vue +124 -0
- package/components/Account/{AccountSettings.vue → Settings/AccountSettings.vue} +4 -4
- package/components/Account/Settings/ChangeEmail.vue +136 -0
- package/components/Account/Settings/ChangeName.vue +82 -0
- package/components/Account/Settings/ChangePassword.vue +91 -0
- package/components/Address/Address.vue +38 -57
- package/components/Address/AddressBook.vue +77 -57
- package/components/Address/AddressSelect.vue +94 -87
- package/components/Address/Edit.vue +253 -265
- package/components/Address/PostalCode.vue +22 -21
- package/components/AgeGate.vue +11 -5
- package/components/Auth/Login.vue +62 -44
- package/components/Auth/Register.vue +82 -60
- package/components/Auth/ResetPassword.vue +45 -30
- package/components/Cart/AgeVerification/AgeChecker.vue +3 -3
- package/components/Cart/CartBadge.vue +15 -4
- package/components/Cart/CartBox.vue +19 -11
- package/components/Cart/CartItem.vue +3 -3
- package/components/Cart/CartMode.vue +6 -5
- package/components/Cart/CartPreview.vue +24 -18
- package/components/Cart/Coupon.vue +4 -5
- package/components/Cart/CreditCard/Everyware.vue +10 -10
- package/components/Cart/CreditCard/ExtendedCreditCard.vue +5 -5
- package/components/Cart/CreditCard/SquarePay.vue +18 -16
- package/components/Cart/CreditCard/StandardCreditCard.vue +9 -9
- package/components/Cart/Delivery/Delivery.vue +16 -12
- package/components/Cart/Delivery/DeliveryAddress.vue +1 -1
- package/components/Cart/Delivery/DeliveryMethods.vue +1 -1
- package/components/Cart/Delivery/DeliveryOptions.vue +15 -9
- package/components/Cart/Delivery/DeliveryTypes.vue +8 -5
- package/components/Cart/Delivery/ReservationSlots.vue +14 -8
- package/components/Cart/Disclaimer.vue +1 -1
- package/components/Cart/OrderConfirmation.vue +1 -1
- package/components/Cart/Payment/Payment.vue +37 -33
- package/components/Cart/Payment/PaymentMethods.vue +6 -4
- package/components/Cart/ReviewAndSubmit.vue +9 -7
- package/components/Cart/ShoppingCart.vue +42 -31
- package/components/Cart/Store/actions.js +1 -1
- package/components/Cart/Store/getters.js +2 -1
- package/components/Cart/Store/index.js +1 -1
- package/components/Cart/Store/mutations.js +7 -5
- package/components/Cart/UserIdentity.vue +1 -1
- package/components/Category/CategoryFilter.vue +128 -114
- package/components/Category/CategorySort.vue +44 -32
- package/components/Category/LoadMore.vue +39 -23
- package/components/DeliverTo.vue +10 -15
- package/components/DeliveryNotice.vue +72 -68
- package/components/DobInput.vue +23 -23
- package/components/Gmaps/GmapsAutocomplete.vue +139 -78
- package/components/Gmaps/GmapsLocations.vue +1 -1
- package/components/Gmaps/GmapsSingleLocation.vue +121 -87
- package/components/ModalContainer/ModalContainer.vue +12 -9
- package/components/ModalContainer/index.js +61 -18
- package/components/Product/AddToCart.vue +237 -221
- package/components/Product/BoxAddToCart.vue +114 -86
- package/components/Product/Compare.vue +68 -48
- package/components/Product/CompareBox.vue +128 -123
- package/components/Product/Lookup.vue +92 -65
- package/components/Product/Photo.vue +105 -66
- package/components/Product/Price.vue +64 -43
- package/components/Product/ProductAutocomplete.vue +52 -57
- package/components/Product/ProductBox.vue +61 -38
- package/components/Product/ProductImages.vue +83 -86
- package/components/Product/Quantity.vue +115 -53
- package/components/Product/QuickView.vue +52 -45
- package/components/Product/RelatedProducts.vue +88 -23
- package/components/Product/SKU.vue +27 -8
- package/components/Product/Variants.vue +335 -341
- package/components/Product/reviews-questions/ProductQuestions.vue +226 -198
- package/components/Product/reviews-questions/ProductReviews.vue +122 -107
- package/components/Product/reviews-questions/Review.vue +54 -59
- package/components/Product/reviews-questions/ReviewForm.vue +222 -170
- package/components/Product/reviews-questions/ReviewImages.vue +197 -216
- package/components/Product/reviews-questions/Vote.vue +83 -57
- package/components/QuantityInput.vue +18 -8
- package/components/RangeInput.vue +15 -8
- package/components/Recaptcha.vue +8 -1
- package/components/SelectShippingCountry.vue +81 -62
- package/components/TimedOffer.vue +59 -74
- package/composables/globals.js +53 -0
- package/config.js +5 -2
- package/index.js +41 -10
- package/install.js +75 -0
- package/locales/en.json +2 -1
- package/locales/sr.json +2 -1
- package/package.json +43 -30
- package/utils/directives.js +28 -45
- package/utils/event-bus.js +56 -0
- package/utils/filters.js +24 -7
- package/utils/{gmaps.js → google/gmaps.js} +43 -10
- package/utils/{google-analytics-eec.js → google/google-analytics-eec.js} +7 -7
- package/babel.config.js +0 -5
- package/components/Account/ChangeEmail.vue +0 -133
- package/components/Account/ChangeName.vue +0 -92
- package/components/Account/ChangePassword.vue +0 -94
- package/components/Account/CreditCards.vue +0 -18
- package/components/Account/Orders.vue +0 -110
- package/components/Account/Settings.vue +0 -18
- package/components/Cart/Delivery/DeliveryAddressGuest.spec.js +0 -128
- package/components/Cart/Delivery/DeliveryTypes.spec.js +0 -83
- package/components/Cart/PCIBadge/SecurityMetrics.vue +0 -11
- package/components/Instagram.vue +0 -49
- package/components/ProductImageModal.vue +0 -41
- package/jest.config.js +0 -16
- package/test/e2e/.babelrc.js +0 -8
- package/test/e2e/.eslintrc.js +0 -11
- package/test/e2e/accAuth.spec.js +0 -64
- package/test/e2e/ageGate.spec.js +0 -26
- package/test/e2e/checkout.spec.js +0 -106
- package/test/e2e/compare.spec.js +0 -52
- package/test/e2e/config/data.js +0 -21
- package/test/e2e/config/routes.js +0 -11
- package/test/e2e/region.spec.js +0 -46
- package/test/e2e/search.spec.js +0 -32
- package/tests/vueBuefy.js +0 -4
- package/tsconfig.json +0 -8
|
@@ -14,255 +14,271 @@
|
|
|
14
14
|
</div>
|
|
15
15
|
</template>
|
|
16
16
|
|
|
17
|
-
<script>
|
|
18
|
-
import
|
|
17
|
+
<script setup>
|
|
18
|
+
import { ref, computed, onMounted, onBeforeUnmount, nextTick, getCurrentInstance } from 'vue'
|
|
19
|
+
import { useBuefy, useBus, useMq, useT } from '../../composables/globals'
|
|
19
20
|
import _ from 'underscore'
|
|
20
21
|
import animateCSS from '../../utils/animate'
|
|
21
|
-
import GoogleAnalyticsEEC from '../../utils/google-analytics-eec.js'
|
|
22
|
+
import GoogleAnalyticsEEC from '../../utils/google/google-analytics-eec.js'
|
|
23
|
+
import { Cart } from '../../api'
|
|
24
|
+
import Quantity from './Quantity.vue'
|
|
22
25
|
|
|
23
|
-
|
|
26
|
+
defineOptions({ name: 'AddToCart' })
|
|
24
27
|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
components: { Quantity },
|
|
30
|
-
|
|
31
|
-
props: {
|
|
32
|
-
inStock: {
|
|
33
|
-
type: Boolean,
|
|
34
|
-
default: true
|
|
35
|
-
},
|
|
36
|
-
quantityEnabled: {
|
|
37
|
-
type: Boolean,
|
|
38
|
-
default: false
|
|
39
|
-
},
|
|
40
|
-
buyNowEnabled: {
|
|
41
|
-
type: Boolean,
|
|
42
|
-
default: false
|
|
43
|
-
},
|
|
44
|
-
product: {
|
|
45
|
-
type: Object,
|
|
46
|
-
default: function () {
|
|
47
|
-
return {}
|
|
48
|
-
}
|
|
49
|
-
}
|
|
28
|
+
const props = defineProps({
|
|
29
|
+
inStock: {
|
|
30
|
+
type: Boolean,
|
|
31
|
+
default: true
|
|
50
32
|
},
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
mode: 'add',
|
|
59
|
-
product_id: '',
|
|
60
|
-
qty: 1,
|
|
61
|
-
submitEnabled: true,
|
|
62
|
-
variantModalActive: false
|
|
63
|
-
}
|
|
33
|
+
quantityEnabled: {
|
|
34
|
+
type: Boolean,
|
|
35
|
+
default: false
|
|
36
|
+
},
|
|
37
|
+
buyNowEnabled: {
|
|
38
|
+
type: Boolean,
|
|
39
|
+
default: false
|
|
64
40
|
},
|
|
41
|
+
product: {
|
|
42
|
+
type: Object,
|
|
43
|
+
default: () => ({})
|
|
44
|
+
}
|
|
45
|
+
})
|
|
65
46
|
|
|
66
|
-
|
|
67
|
-
eecProduct() {
|
|
68
|
-
let eecProduct = {
|
|
69
|
-
item_id: this.product.id,
|
|
70
|
-
item_name: this.product.name,
|
|
71
|
-
price: this.product.price,
|
|
72
|
-
item_brand: this.product.brand ? this.product.brand.name : '',
|
|
73
|
-
item_category: this.product?.category?.path.startsWith('/') ? this.product?.category?.path.substr(1) : this.product?.category?.path,
|
|
74
|
-
quantity: parseInt(this.qty)
|
|
75
|
-
}
|
|
76
|
-
if (this.selectedVariant) {
|
|
77
|
-
eecProduct = {
|
|
78
|
-
item_id: this.product.id, //this.selectedVariant.id
|
|
79
|
-
item_name: this.product.name, //this.product.name + ' - ' + _.pluck(this.selectedVariant.options, 'value').join(', '),
|
|
80
|
-
price: this.selectedVariant.price,
|
|
81
|
-
item_brand: this.product.brand ? this.product.brand.name : '',
|
|
82
|
-
item_category: this.product?.category?.path.startsWith('/') ? this.product?.category?.path.substr(1) : this.product?.category?.path,
|
|
83
|
-
item_variant: _.pluck(this.selectedVariant.options, 'value').join(', '),
|
|
84
|
-
quantity: parseInt(this.qty)
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
//console.log('eecProduct ', eecProduct)
|
|
88
|
-
return eecProduct
|
|
89
|
-
},
|
|
47
|
+
const emit = defineEmits(['success', 'update'])
|
|
90
48
|
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
product.item_name += ' - ' + _.pluck(this.selectedVariant.options, 'value').join(', ')
|
|
98
|
-
product.image_url = variantImage?.url
|
|
99
|
-
}
|
|
100
|
-
return product
|
|
101
|
-
},
|
|
49
|
+
// Get global properties and injections
|
|
50
|
+
const instance = getCurrentInstance()
|
|
51
|
+
const $bus = useBus()
|
|
52
|
+
const mq = useMq()
|
|
53
|
+
const $buefy = useBuefy()
|
|
54
|
+
const { t: $t } = useT()
|
|
102
55
|
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
} else {
|
|
114
|
-
throw new Error(this.$t('cart.updateCartErrorUnknown'))
|
|
115
|
-
}
|
|
116
|
-
return response.data
|
|
117
|
-
} catch (error) {
|
|
118
|
-
if (!error.message) {
|
|
119
|
-
error.message = this.$t('cart.updateCartError', error.status)
|
|
120
|
-
}
|
|
121
|
-
this.$buefy.dialog.alert({
|
|
122
|
-
title: this.$t('global.error'),
|
|
123
|
-
message: error.message,
|
|
124
|
-
confirmText: 'OK'
|
|
125
|
-
})
|
|
126
|
-
} finally {
|
|
127
|
-
this.loadingAddToCart = false
|
|
128
|
-
this.loadingBuyNow = false
|
|
129
|
-
}
|
|
130
|
-
},
|
|
56
|
+
// Reactive state
|
|
57
|
+
const loadingAddToCart = ref(false)
|
|
58
|
+
const loadingBuyNow = ref(false)
|
|
59
|
+
const variantIds = ref([])
|
|
60
|
+
const selectedVariant = ref(null)
|
|
61
|
+
const mode = ref('add')
|
|
62
|
+
const product_id = ref('')
|
|
63
|
+
const qty = ref(1)
|
|
64
|
+
const submitEnabled = ref(true)
|
|
65
|
+
const variantModalActive = ref(false)
|
|
131
66
|
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
67
|
+
// Methods
|
|
68
|
+
const eecProduct = () => {
|
|
69
|
+
let eecProduct = {
|
|
70
|
+
item_id: props.product.id,
|
|
71
|
+
item_name: props.product.name,
|
|
72
|
+
price: props.product.price,
|
|
73
|
+
item_brand: props.product.brand ? props.product.brand.name : '',
|
|
74
|
+
item_category: props.product?.category?.path.startsWith('/') ? props.product?.category?.path.substr(1) : props.product?.category?.path,
|
|
75
|
+
quantity: parseInt(qty.value)
|
|
76
|
+
}
|
|
77
|
+
if (selectedVariant.value) {
|
|
78
|
+
eecProduct = {
|
|
79
|
+
item_id: props.product.id, //selectedVariant.value.id
|
|
80
|
+
item_name: props.product.name, //props.product.name + ' - ' + _.pluck(selectedVariant.value.options, 'value').join(', '),
|
|
81
|
+
price: selectedVariant.value.price,
|
|
82
|
+
item_brand: props.product.brand ? props.product.brand.name : '',
|
|
83
|
+
item_category: props.product?.category?.path.startsWith('/') ? props.product?.category?.path.substr(1) : props.product?.category?.path,
|
|
84
|
+
item_variant: _.pluck(selectedVariant.value.options, 'value').join(', '),
|
|
85
|
+
quantity: parseInt(qty.value)
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
//console.log('eecProduct ', eecProduct)
|
|
89
|
+
return eecProduct
|
|
90
|
+
}
|
|
142
91
|
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
92
|
+
const productDetails = () => {
|
|
93
|
+
let product = eecProduct()
|
|
94
|
+
product.image_url = props.product.images && props.product.images[0] ? props.product.images[0].url : ''
|
|
95
|
+
if (selectedVariant.value) {
|
|
96
|
+
let variantImage = _.findWhere(props.product.images, { id: selectedVariant.value.default_image_id })
|
|
97
|
+
product.image_url = variantImage?.url
|
|
98
|
+
}
|
|
99
|
+
return product
|
|
100
|
+
}
|
|
148
101
|
|
|
149
|
-
|
|
150
|
-
|
|
102
|
+
const updateCart = async () => {
|
|
103
|
+
try {
|
|
104
|
+
let response = await Cart.update({
|
|
105
|
+
mode: mode.value,
|
|
106
|
+
id: product_id.value,
|
|
107
|
+
qty: qty.value
|
|
108
|
+
})
|
|
109
|
+
//console.log(response.data)
|
|
110
|
+
if (response.data) {
|
|
111
|
+
$bus.emit('updateCart', response.data)
|
|
112
|
+
} else {
|
|
113
|
+
throw new Error($t('cart.updateCartErrorUnknown'))
|
|
114
|
+
}
|
|
115
|
+
return response.data
|
|
116
|
+
} catch (error) {
|
|
117
|
+
if (!error.message) {
|
|
118
|
+
error.message = $t('cart.updateCartError', error.status)
|
|
119
|
+
}
|
|
120
|
+
$buefy.dialog.alert({
|
|
121
|
+
title: $t('global.error'),
|
|
122
|
+
message: error.message,
|
|
123
|
+
confirmText: 'OK'
|
|
124
|
+
})
|
|
125
|
+
} finally {
|
|
126
|
+
loadingAddToCart.value = false
|
|
127
|
+
loadingBuyNow.value = false
|
|
128
|
+
}
|
|
129
|
+
}
|
|
151
130
|
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
131
|
+
const variantSelected = () => {
|
|
132
|
+
variantModalActive.value = false
|
|
133
|
+
//console.log('variant ids ', variantIds.value, 'product ', product_id.value)
|
|
134
|
+
if (!_.isEmpty(variantIds.value) && !_.contains(variantIds.value, product_id.value)) {
|
|
135
|
+
$bus.emit('noVariantSelected')
|
|
136
|
+
if (mq.value === 'mobile' && variantModalActive.value) {
|
|
137
|
+
animateCSS('.wkl-modal-container .variant-options', 'pulse')
|
|
138
|
+
} else {
|
|
139
|
+
animateCSS('.wkl-pp-variants', 'pulse')
|
|
140
|
+
}
|
|
156
141
|
|
|
157
|
-
|
|
158
|
-
|
|
142
|
+
if (mq.value === 'mobile') {
|
|
143
|
+
submitEnabled.value = false
|
|
144
|
+
$bus.emit('scrollToVariants')
|
|
145
|
+
variantModalActive.value = true
|
|
146
|
+
}
|
|
159
147
|
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
}
|
|
148
|
+
loadingAddToCart.value = false
|
|
149
|
+
loadingBuyNow.value = false
|
|
163
150
|
|
|
164
|
-
|
|
151
|
+
return false
|
|
152
|
+
}
|
|
153
|
+
return true
|
|
154
|
+
}
|
|
165
155
|
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
}
|
|
156
|
+
const buyNow = async (event) => {
|
|
157
|
+
loadingBuyNow.value = true
|
|
169
158
|
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
window.location.href = '/shopping-cart'
|
|
174
|
-
})
|
|
175
|
-
} else {
|
|
176
|
-
this.logMessage('GTM is not loaded')
|
|
177
|
-
setTimeout(() => {
|
|
178
|
-
window.location.href = '/shopping-cart'
|
|
179
|
-
}, 300)
|
|
180
|
-
}
|
|
181
|
-
},
|
|
159
|
+
if (!variantSelected()) {
|
|
160
|
+
return false
|
|
161
|
+
}
|
|
182
162
|
|
|
183
|
-
|
|
184
|
-
this.loadingAddToCart = true
|
|
185
|
-
if (!this.variantSelected()) {
|
|
186
|
-
return false
|
|
187
|
-
}
|
|
188
|
-
let cartResponse = await this.updateCart()
|
|
189
|
-
if (cartResponse) {
|
|
190
|
-
this.$emit('success')
|
|
191
|
-
this.$bus.$emit('addToCart', this.productDetails(), this.el$)
|
|
192
|
-
if (!!window.google_tag_manager) {
|
|
193
|
-
GoogleAnalyticsEEC.addToCart(this.eecProduct(), () => {
|
|
194
|
-
this.loadingAddToCart = false
|
|
195
|
-
})
|
|
196
|
-
}
|
|
197
|
-
}
|
|
198
|
-
},
|
|
163
|
+
let cartResponse = await updateCart()
|
|
199
164
|
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
this.selectedVariant = null
|
|
204
|
-
this.submitEnabled = false
|
|
205
|
-
this.product_id = null
|
|
206
|
-
} else {
|
|
207
|
-
this.selectedVariant = _.findWhere(this.product.variants, {
|
|
208
|
-
id: parseInt(variant_id)
|
|
209
|
-
})
|
|
210
|
-
this.submitEnabled = true
|
|
211
|
-
this.product_id = parseInt(variant_id)
|
|
212
|
-
GoogleAnalyticsEEC.productView(this.eecProduct())
|
|
213
|
-
//console.log('addtocart ', this.selectedVariant, this.product_id)
|
|
214
|
-
}
|
|
215
|
-
},
|
|
165
|
+
if (!cartResponse) {
|
|
166
|
+
return false
|
|
167
|
+
}
|
|
216
168
|
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
element.classList.add('add-to-cart-fixed-footer')
|
|
230
|
-
pagetop.classList.add('pos2')
|
|
231
|
-
} else {
|
|
232
|
-
element.classList.remove('add-to-cart-fixed-footer')
|
|
233
|
-
pagetop.classList.remove('pos2')
|
|
234
|
-
}
|
|
235
|
-
}
|
|
236
|
-
|
|
237
|
-
window.addEventListener('scroll', checkPosition);
|
|
238
|
-
checkPosition();
|
|
239
|
-
},
|
|
169
|
+
if (!!window.google_tag_manager) {
|
|
170
|
+
GoogleAnalyticsEEC.addToCart(eecProduct(), () => {
|
|
171
|
+
loadingBuyNow.value = false
|
|
172
|
+
window.location.href = '/shopping-cart'
|
|
173
|
+
})
|
|
174
|
+
} else {
|
|
175
|
+
console.log('GTM is not loaded')
|
|
176
|
+
setTimeout(() => {
|
|
177
|
+
window.location.href = '/shopping-cart'
|
|
178
|
+
}, 300)
|
|
179
|
+
}
|
|
180
|
+
}
|
|
240
181
|
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
182
|
+
const addToCart = async (event) => {
|
|
183
|
+
loadingAddToCart.value = true
|
|
184
|
+
if (!variantSelected()) {
|
|
185
|
+
return false
|
|
186
|
+
}
|
|
187
|
+
let cartResponse = await updateCart()
|
|
188
|
+
if (cartResponse) {
|
|
189
|
+
emit('success')
|
|
190
|
+
$bus.emit('addToCart', productDetails(), instance.proxy.$el)
|
|
191
|
+
if (!!window.google_tag_manager) {
|
|
192
|
+
GoogleAnalyticsEEC.addToCart(eecProduct(), () => {
|
|
193
|
+
loadingAddToCart.value = false
|
|
246
194
|
})
|
|
247
195
|
}
|
|
248
|
-
}
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
const onSelectVariant = (variant_id) => {
|
|
200
|
+
//console.log('receiving selectVariant ', variant_id)
|
|
201
|
+
if (!variant_id) {
|
|
202
|
+
selectedVariant.value = null
|
|
203
|
+
submitEnabled.value = false
|
|
204
|
+
product_id.value = null
|
|
205
|
+
} else {
|
|
206
|
+
selectedVariant.value = _.findWhere(props.product.variants, {
|
|
207
|
+
id: parseInt(variant_id)
|
|
208
|
+
})
|
|
209
|
+
submitEnabled.value = true
|
|
210
|
+
product_id.value = parseInt(variant_id)
|
|
211
|
+
GoogleAnalyticsEEC.productView(eecProduct())
|
|
212
|
+
//console.log('addtocart ', selectedVariant.value, product_id.value)
|
|
213
|
+
}
|
|
214
|
+
}
|
|
249
215
|
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
216
|
+
const handleScroll = () => {
|
|
217
|
+
if (mq.value !== 'mobile') {
|
|
218
|
+
return
|
|
219
|
+
}
|
|
220
|
+
const element = instance.proxy.$el
|
|
221
|
+
const pagetop = document.querySelector('#pagetop')
|
|
222
|
+
const elementPosition = element.getBoundingClientRect().top
|
|
223
|
+
|
|
224
|
+
const checkPosition = () => {
|
|
225
|
+
const scrollPosition = window.scrollY
|
|
226
|
+
|
|
227
|
+
if (scrollPosition > elementPosition) {
|
|
228
|
+
element.classList.add('add-to-cart-fixed-footer')
|
|
229
|
+
pagetop?.classList.add('pos2')
|
|
230
|
+
} else {
|
|
231
|
+
element.classList.remove('add-to-cart-fixed-footer')
|
|
232
|
+
pagetop?.classList.remove('pos2')
|
|
253
233
|
}
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
window.addEventListener('scroll', checkPosition)
|
|
237
|
+
checkPosition()
|
|
238
|
+
|
|
239
|
+
// Store cleanup function
|
|
240
|
+
return () => window.removeEventListener('scroll', checkPosition)
|
|
241
|
+
}
|
|
254
242
|
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
this.handleScroll()
|
|
263
|
-
})
|
|
243
|
+
const onUpdateQty = (qty_value) => {
|
|
244
|
+
qty.value = qty_value
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
const handleBusEvents = () => {
|
|
248
|
+
$bus.on('selectVariant', onSelectVariant)
|
|
249
|
+
$bus.on('updateQty', onUpdateQty)
|
|
264
250
|
|
|
265
|
-
|
|
251
|
+
// Return cleanup function
|
|
252
|
+
return () => {
|
|
253
|
+
$bus.off('selectVariant', onSelectVariant)
|
|
254
|
+
$bus.off('updateQty', onUpdateQty)
|
|
266
255
|
}
|
|
267
256
|
}
|
|
257
|
+
|
|
258
|
+
let cleanupScroll = null
|
|
259
|
+
let cleanupBus = null
|
|
260
|
+
|
|
261
|
+
onMounted(() => {
|
|
262
|
+
if (window.wkl_product) {
|
|
263
|
+
emit('update', window.wkl_product)
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
nextTick(() => {
|
|
267
|
+
if (!product_id.value && props.product.id) {
|
|
268
|
+
product_id.value = props.product.id
|
|
269
|
+
if (props.product.variants && props.product.variants.length > 0) {
|
|
270
|
+
variantIds.value = _.pluck(props.product.variants, 'id')
|
|
271
|
+
}
|
|
272
|
+
}
|
|
273
|
+
cleanupScroll = handleScroll()
|
|
274
|
+
})
|
|
275
|
+
|
|
276
|
+
cleanupBus = handleBusEvents()
|
|
277
|
+
})
|
|
278
|
+
|
|
279
|
+
onBeforeUnmount(() => {
|
|
280
|
+
// Cleanup event listeners
|
|
281
|
+
if (cleanupScroll) cleanupScroll()
|
|
282
|
+
if (cleanupBus) cleanupBus()
|
|
283
|
+
})
|
|
268
284
|
</script>
|