@lancom/shared 0.0.211 → 0.0.213

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.
Files changed (22) hide show
  1. package/assets/js/api/admin.js +39 -0
  2. package/assets/js/api/index.js +3 -3
  3. package/components/checkout/order/order-payment-information/order-payment-information.vue +1 -1
  4. package/components/checkout/order/order-review/order-review.vue +2 -2
  5. package/components/common/payment/payment_card/payment-card.scss +0 -0
  6. package/components/common/payment/payment_card/payment-card.vue +45 -0
  7. package/components/{checkout/payment/payment-cart/payment-cart.vue → common/payment/payment_card/pinpayment/pinpayment.vue} +2 -1
  8. package/components/common/payment/payment_card/stripe/stripe.scss +0 -0
  9. package/components/common/payment/payment_card/stripe/stripe.vue +74 -0
  10. package/components/modals/payment_modal/payment-modal.vue +26 -116
  11. package/components/order/order_payment/order-payment.vue +6 -5
  12. package/components/product/product.vue +5 -3
  13. package/mixins/payment.js +2 -2
  14. package/nuxt.config.js +45 -30
  15. package/package.json +1 -1
  16. package/store/index.js +21 -0
  17. package/store/order.js +3 -2
  18. /package/components/{checkout/payment/payment-cart/payment-cart.scss → common/payment/payment_card/pinpayment/pinpayment.scss} +0 -0
  19. /package/components/{checkout → common}/payment/payment_failed/payment-failed.scss +0 -0
  20. /package/components/{checkout → common}/payment/payment_failed/payment-failed.vue +0 -0
  21. /package/components/{checkout → common}/payment/payment_success/payment-success.scss +0 -0
  22. /package/components/{checkout → common}/payment/payment_success/payment-success.vue +0 -0
@@ -256,6 +256,9 @@ export default {
256
256
  fetchSimpleProducts(params) {
257
257
  return _get('admin/simple-products', params);
258
258
  },
259
+ clearCanonicalProductFromSimpleProduct(product, simpleProduct) {
260
+ return _delete(`admin/products/${product}/simple-products/${simpleProduct}/canonical`);
261
+ },
259
262
  fetchProductTypes(params) {
260
263
  return _get('admin/product-types', params);
261
264
  },
@@ -374,6 +377,21 @@ export default {
374
377
  removeWebhook(id) {
375
378
  return _delete(`admin/webhooks/${id}`);
376
379
  },
380
+ async fetchGrabbers(params) {
381
+ return sortByName(await _get('admin/grabbers', params));
382
+ },
383
+ fetchGrabberById(id) {
384
+ return _get(`admin/grabbers/${id}`);
385
+ },
386
+ saveGrabber(grabber) {
387
+ return grabber._id ? _put(`admin/grabbers/${grabber._id}`, grabber) : _post('admin/grabbers', grabber);
388
+ },
389
+ runGrabber(grabber) {
390
+ return _post(`admin/grabbers/${grabber._id}/run`, grabber);
391
+ },
392
+ removeGrabber(id) {
393
+ return _delete(`admin/grabbers/${id}`);
394
+ },
377
395
  async fetchCurrencies(params) {
378
396
  return sortByName(await _get('admin/currencies', params));
379
397
  },
@@ -416,6 +434,9 @@ export default {
416
434
  removeWarehouse(id) {
417
435
  return _delete(`admin/warehouse/${id}`);
418
436
  },
437
+ addProductToWarehouse(id, data) {
438
+ return _post(`admin/warehouse/${id}/product`, data);
439
+ },
419
440
  fetchWarehouseTaskById(id) {
420
441
  return _get(`admin/warehouse-task/${id}`);
421
442
  },
@@ -455,6 +476,12 @@ export default {
455
476
  moveToWarehouseLocations(move) {
456
477
  return _post(`admin/warehouse-locations/move/bulk`, move);
457
478
  },
479
+ fetchWarehouseCanonicalProductsLocations(warehouse) {
480
+ return _get(`admin/warehouses/${warehouse}/canonical-products-locations`);
481
+ },
482
+ removeCanonicalProductLocation(warehouse, canonicalProduct, location) {
483
+ return _delete(`admin/warehouses/${warehouse}/canonical-product/${canonicalProduct}/locations/${location}`);
484
+ },
458
485
  async fetchBanners(params) {
459
486
  return sortByName(await _get('admin/banners', params));
460
487
  },
@@ -479,6 +506,18 @@ export default {
479
506
  removeMenu(id) {
480
507
  return _delete(`admin/menus/${id}`);
481
508
  },
509
+ fetchPrintFactories(params) {
510
+ return _get('admin/print-factories', params);
511
+ },
512
+ fetchPrintFactoryById(id) {
513
+ return _get(`admin/print-factories/${id}`);
514
+ },
515
+ savePrintFactory(factory) {
516
+ return factory._id ? _put(`admin/print-factories/${factory._id}`, factory) : _post('admin/print-factories', factory);
517
+ },
518
+ removePrintFactory(id) {
519
+ return _delete(`admin/print-factories/${id}`);
520
+ },
482
521
  fetchPrintTypes(params) {
483
522
  return _get('admin/print-types', params);
484
523
  },
@@ -93,9 +93,9 @@ const api = {
93
93
  fetchOrderByToken(token, params) {
94
94
  return _get(`order/token/${token}`, params);
95
95
  },
96
- createOrderPayment(id, card, shop, invoiceId) {
97
- const url = invoiceId ? `shop/${shop}/order/${id}/invoice/${invoiceId}/payment` : `shop/${shop}/order/${id}/payment`;
98
- return _post(url, card);
96
+ createOrderPayment(id, { card, shop, country, invoice, payment }) {
97
+ const url = invoice ? `shop/${shop}/order/${id}/invoice/${invoice}/payment` : `shop/${shop}/order/${id}/payment`;
98
+ return _post(url, { card, country, payment });
99
99
  },
100
100
  addOrderTimeline(id, item) {
101
101
  return _post(`order/${id}/timeline`, item);
@@ -75,7 +75,7 @@
75
75
  import { mapGetters, mapMutations, mapActions } from 'vuex';
76
76
  import { generateOrderData } from '@lancom/shared/assets/js/utils/order';
77
77
  import gtm from '@lancom/shared/assets/js/utils/gtm';
78
- import PaymentCart from '@lancom/shared/components/checkout/payment/payment-cart/payment-cart';
78
+ import PaymentCart from '@lancom/shared/components/common/payment/payment_card/pinpayment/pinpayment';
79
79
  import ProgressStepsControls from '@lancom/shared/components/common/progress_steps/progress_steps_controls/progress-steps-controls';
80
80
  import { ORDER_PAYMENT_METHOD } from '@lancom/shared/assets/js/constants/order';
81
81
  import payment from '@lancom/shared/mixins/payment';
@@ -45,8 +45,8 @@ import { groupSimpleProducts } from '@lancom/shared/assets/js/utils/cart';
45
45
  import ProgressStepsControls from '@lancom/shared/components/common/progress_steps/progress_steps_controls/progress-steps-controls';
46
46
  import { ORDER_PAYMENT_METHOD, ORDER_STEPS } from '@lancom/shared/assets/js/constants/order';
47
47
  import payment from '@lancom/shared/mixins/payment';
48
- import PaymentSuccess from '@lancom/shared/components/checkout/payment/payment_success/payment-success';
49
- import PaymentFailed from '@lancom/shared/components/checkout/payment/payment_failed/payment-failed';
48
+ import PaymentSuccess from '@lancom/shared/components/common/payment/payment_success/payment-success';
49
+ import PaymentFailed from '@lancom/shared/components/common/payment/payment_failed/payment-failed';
50
50
 
51
51
  export default {
52
52
  name: 'OrderReview',
@@ -0,0 +1,45 @@
1
+ <template>
2
+ <div class="Card__wrapper">
3
+ <client-only>
4
+ <component
5
+ :is="cardComponent"
6
+ ref="card"
7
+ :paymentData="paymentData"
8
+ @inited="$emit('inited')" />
9
+ </client-only>
10
+ </div>
11
+ </template>
12
+
13
+ <script>
14
+ import { mapGetters } from 'vuex';
15
+
16
+ export default {
17
+ name: 'PaymentCard',
18
+ components: {
19
+ Pinpayment: () => import('./pinpayment/pinpayment'),
20
+ Stripe: () => import('./stripe/stripe')
21
+ },
22
+ props: {
23
+ paymentData: {
24
+ type: Object,
25
+ required: true
26
+ }
27
+ },
28
+ computed: {
29
+ ...mapGetters(['payment']),
30
+ cardComponent() {
31
+ console.log('payment: ', this.payment);
32
+ return 'stripe';
33
+ }
34
+ },
35
+ methods: {
36
+ async tokenize() {
37
+ return await this.$refs.card.tokenize();
38
+ },
39
+ }
40
+ };
41
+ </script>
42
+
43
+ <style lang="scss" scoped>
44
+ @import 'payment-card.scss';
45
+ </style>
@@ -163,6 +163,7 @@ export default {
163
163
 
164
164
  this.fields.on('ready', () => {
165
165
  this.loading = false;
166
+ this.$emit('inited');
166
167
  });
167
168
  },
168
169
  tokenize() {
@@ -199,5 +200,5 @@ export default {
199
200
  </script>
200
201
 
201
202
  <style lang="scss" scoped>
202
- @import 'payment-cart.scss';
203
+ @import 'pinpayment.scss';
203
204
  </style>
@@ -0,0 +1,74 @@
1
+ <template>
2
+ <div>
3
+ <div v-if="loadedStripe">
4
+ <stripe-element-card
5
+ ref="card"
6
+ :pk="stripe" />
7
+ </div>
8
+ </div>
9
+ </template>
10
+
11
+ <script>
12
+ import { StripeElementCard } from '@vue-stripe/vue-stripe';
13
+ import { mapGetters } from 'vuex';
14
+
15
+ let stripeStartLoaded = false;
16
+
17
+ export default {
18
+ name: 'PaymentCardStripe',
19
+ components: {
20
+ StripeElementCard
21
+ },
22
+ data() {
23
+ return {
24
+ loadedStripe: false
25
+ }
26
+ },
27
+ computed: {
28
+ ...mapGetters(['payment']),
29
+ stripe() {
30
+ return this.payment.clientKey;
31
+ }
32
+ },
33
+ created() {
34
+ this.loadStripe();
35
+ },
36
+ methods: {
37
+ async tokenize() {
38
+ const data = {
39
+ ...this.$refs.card.element,
40
+ };
41
+ const { token, error } = await this.$refs.card.stripe.createToken(data);
42
+ if (error) {
43
+ throw new Error(error.message);
44
+ }
45
+ return token;
46
+ },
47
+ loadStripe() {
48
+ if (process.browser) {
49
+ if (!stripeStartLoaded) {
50
+ stripeStartLoaded = true;
51
+ let domElement = document.createElement('script');
52
+ domElement.setAttribute('src', 'https://js.stripe.com/v3/');
53
+ domElement.onload = () => {
54
+ this.loadedStripe = true;
55
+ };
56
+ domElement.onerror = () => {
57
+ setTimeout(() => this.loadStripe(), 1000);
58
+ };
59
+ document.body.appendChild(domElement);
60
+ } else {
61
+ let repeated = 0;
62
+ let timer = setInterval(() => {
63
+ if (typeof window.Stripe !== 'undefined' || repeated++ > 20) {
64
+ this.loadedStripe = true;
65
+ this.$emit('inited');
66
+ clearInterval(timer);
67
+ }
68
+ }, 500);
69
+ }
70
+ }
71
+ }
72
+ }
73
+ };
74
+ </script>
@@ -28,52 +28,14 @@
28
28
  v-show="!isVisibleChargeMessage"
29
29
  class="lc_modal__content">
30
30
  <div
31
- v-if="loadingFields"
31
+ v-if="loadingCard"
32
32
  class="lc_modal__spinner">
33
33
  <spinner />
34
34
  </div>
35
- <div class="form-row">
36
- <div
37
- id="name"
38
- class="PaymentModal__field-container">
39
- </div>
40
- <div
41
- id="errors_for_name"
42
- class="error_message">
43
- </div>
44
- </div>
45
- <div class="form-row">
46
- <div
47
- id="number"
48
- class="PaymentModal__field-container">
49
- </div>
50
- <div
51
- id="errors_for_number"
52
- class="error_message">
53
- </div>
54
- </div>
55
- <div class="form-row--cols">
56
- <div class="form-col col-half">
57
- <div
58
- id="cvc"
59
- class="PaymentModal__field-container">
60
- </div>
61
- <div
62
- id="errors_for_cvc"
63
- class="error_message">
64
- </div>
65
- </div>
66
- <div class="form-col col-half">
67
- <div
68
- id="expiry"
69
- class="PaymentModal__field-container">
70
- </div>
71
- <div
72
- id="errors_for_expiry"
73
- class="error_message">
74
- </div>
75
- </div>
76
- </div>
35
+ <payment-card
36
+ ref="card"
37
+ :paymentData="orderData"
38
+ @inited="initedCard"/>
77
39
  <div class="form-row PaymentModal__terms">
78
40
  <label class="form-label PaymentModal__label-with-checkbox">
79
41
  <checkbox v-model="agreeTermsAndCondition" />
@@ -118,15 +80,17 @@ import { mapGetters, mapActions, mapMutations } from 'vuex';
118
80
  import { price } from '@lancom/shared/assets/js/utils/filters';
119
81
  import gtm from '@lancom/shared/assets/js/utils/gtm';
120
82
  import gapis from '@lancom/shared/assets/js/utils/gapis';
121
- import PaymentSuccess from '@lancom/shared/components/checkout/payment/payment_success/payment-success';
122
- import PaymentFailed from '@lancom/shared/components/checkout/payment/payment_failed/payment-failed';
83
+ import PaymentSuccess from '@lancom/shared/components/common/payment/payment_success/payment-success';
84
+ import PaymentFailed from '@lancom/shared/components/common/payment/payment_failed/payment-failed';
85
+ import PaymentCard from '@lancom/shared/components/common/payment/payment_card/payment-card';
123
86
 
124
87
  export default {
125
88
  name: 'PaymentModal',
126
89
  filters: { price },
127
90
  components: {
128
91
  PaymentSuccess,
129
- PaymentFailed
92
+ PaymentFailed,
93
+ PaymentCard
130
94
  },
131
95
  props: {
132
96
  switchModal: {
@@ -140,7 +104,7 @@ export default {
140
104
  data() {
141
105
  return {
142
106
  processing: false,
143
- loadingFields: false,
107
+ loadingCard: false,
144
108
  form: {},
145
109
  fields: null,
146
110
  agreeTermsAndCondition: false,
@@ -149,7 +113,7 @@ export default {
149
113
  };
150
114
  },
151
115
  computed: {
152
- ...mapGetters(['shop']),
116
+ ...mapGetters(['shop', 'country', 'payment']),
153
117
  ...mapGetters('order', ['orderData']),
154
118
  isVisibleChargeMessage() {
155
119
  return this.isSuccessOrderCharge || this.isFailedOrderCharge;
@@ -163,14 +127,13 @@ export default {
163
127
  return (charge && !charge.success) || this.errorMessage;
164
128
  },
165
129
  disaledBack() {
166
- return this.loadingFields || this.processing;
130
+ return this.loadingCard || this.processing;
167
131
  },
168
132
  disaledSubmit() {
169
- return this.loadingFields || this.processing || !this.agreeTermsAndCondition || !this.confirmCopyright;
133
+ return this.loadingCard || this.processing || !this.agreeTermsAndCondition || !this.confirmCopyright;
170
134
  }
171
135
  },
172
136
  mounted() {
173
- this.initHostedPayment();
174
137
  if (this.orderData.test) {
175
138
  this.clearCart();
176
139
  this.clearTemplate();
@@ -188,46 +151,8 @@ export default {
188
151
  ...mapActions('cart', ['clearCart']),
189
152
  ...mapMutations('product', ['clearTemplate']),
190
153
  ...mapMutations('layers', ['resetLayers']),
191
- initHostedPayment() {
192
- this.loadingFields = true;
193
- this.fields = window.HostedFields.create({
194
- sandbox: process.env.IS_PROD !== 'true',
195
- styles: {
196
- input: {
197
- 'font-size': '16px',
198
- 'font-family': 'helvetica, tahoma, calibri, sans-serif',
199
- color: '#3a3a3a'
200
- },
201
- '.hosted-fields-invalid:not(:focus)': {
202
- color: 'red'
203
- },
204
- 'input::placeholder': {
205
- color: '#B0B0BA'
206
- }
207
- },
208
- fields: {
209
- name: {
210
- selector: '#name',
211
- placeholder: 'Full Name'
212
- },
213
- number: {
214
- selector: '#number',
215
- placeholder: 'Card Number'
216
- },
217
- cvc: {
218
- selector: '#cvc',
219
- placeholder: 'CVC'
220
- },
221
- expiry: {
222
- selector: '#expiry',
223
- placeholder: 'MM/YY'
224
- }
225
- }
226
- });
227
-
228
- this.fields.on('ready', () => {
229
- this.loadingFields = false;
230
- });
154
+ initedCard() {
155
+ this.loadingCard = true;
231
156
  },
232
157
  handleErrors(err) {
233
158
  // err.messages.forEach(({ message }) => this.$toastr.e(message));
@@ -236,7 +161,7 @@ export default {
236
161
  },
237
162
  async proceedPayment(card) {
238
163
  try {
239
- const data = { card, shop: this.shop._id };
164
+ const data = { card, shop: this.shop._id, country: this.country?._id, payment: this.payment };
240
165
  await this.submitPayment(data);
241
166
  this.clearCart();
242
167
  this.clearTemplate();
@@ -264,31 +189,16 @@ export default {
264
189
  this.deleteOrder();
265
190
  this.switchModal('showOrderModal');
266
191
  },
267
- submit() {
192
+ async submit() {
268
193
  this.processing = true;
269
- this.fields.tokenize(
270
- {
271
- publishable_api_key: process.env.PINPAYMENT_PUBLISHABLE_API_KEY,
272
- address_line1: this.orderData.addressLine1,
273
- address_line2: this.orderData.addressLine2,
274
- address_city: this.orderData.city,
275
- address_postcode: this.orderData.postcode,
276
- address_state: this.orderData.state,
277
- address_country: this.orderData.country
278
- },
279
- (err, response) => {
280
- if (!this.processing) {
281
- return;
282
- }
283
-
284
- if (err) {
285
- this.handleErrors(err);
286
- this.processing = false;
287
- } else {
288
- this.proceedPayment(response);
289
- }
290
- }
291
- );
194
+ try {
195
+ const response = await this.$refs.card.tokenize();
196
+ this.proceedPayment(response);
197
+ } catch (e) {
198
+ this.handleErrors(e);
199
+ } finally {
200
+ this.processing = false;
201
+ }
292
202
  },
293
203
  clearFailedCharge() {
294
204
  this.errorMessage = null;
@@ -51,8 +51,8 @@
51
51
  <script>
52
52
  import { mapGetters } from 'vuex';
53
53
  import api from '@lancom/shared/assets/js/api';
54
- import PaymentCart from '@lancom/shared/components/checkout/payment/payment-cart/payment-cart';
55
- import PaymentSuccess from '@lancom/shared/components/checkout/payment/payment_success/payment-success';
54
+ import PaymentCart from '@lancom/shared/components/common/payment/payment_card/pinpayment/pinpayment';
55
+ import PaymentSuccess from '@lancom/shared/components/common/payment/payment_success/payment-success';
56
56
 
57
57
  export default {
58
58
  name: 'OrderPayment',
@@ -77,7 +77,7 @@ export default {
77
77
  };
78
78
  },
79
79
  computed: {
80
- ...mapGetters(['shop']),
80
+ ...mapGetters(['shop', 'country', 'payment']),
81
81
  model() {
82
82
  return this.invoice || this.order;
83
83
  }
@@ -94,8 +94,9 @@ export default {
94
94
  this.processing = true;
95
95
  const card = await this.$refs.paymentCart.tokenize();
96
96
  if (card) {
97
- const { _id: invoiceId } = this.invoice || {};
98
- const { paid } = await api.createOrderPayment(this.order._id, card, this.shop._id, invoiceId);
97
+ const { _id: invoice } = this.invoice || {};
98
+ const payload = { invoice, card, shop: this.shop._id, country: this.country?._id, payment: this.payment };
99
+ const { paid } = await api.createOrderPayment(this.order._id, payload);
99
100
  this.model.paid = paid;
100
101
  }
101
102
  } catch (e) {
@@ -48,7 +48,9 @@ import ProductFabricAndSizeInfo from './layouts/product_fabric_and_size_info/pro
48
48
  import ProductPackaging from './layouts/product_packaging/product-packaging';
49
49
  import ProductModelMeasurements from './layouts/product_model_measurements/product-model-measurements';
50
50
  import ProductSizeTable from './layouts/product_size_table/product-size-table';
51
-
51
+ import RelatedProducts from '@lancom/shared/components/product/related_products/related-products';
52
+ import Gallery from '@lancom/shared/components/product/gallery/gallery';
53
+
52
54
  // import ProductLabelsCustomization from './layouts/product_labels_customization/product-labels-customization';
53
55
 
54
56
  export default {
@@ -61,8 +63,8 @@ export default {
61
63
  ProductPackaging,
62
64
  ProductModelMeasurements,
63
65
  ProductSizeTable,
64
- RelatedProducts: () => import('@lancom/shared/components/product/related_products/related-products'),
65
- Gallery: () => import('@lancom/shared/components/product/gallery/gallery'),
66
+ RelatedProducts,
67
+ Gallery
66
68
  // ProductLabelsCustomization
67
69
  },
68
70
  computed: {
package/mixins/payment.js CHANGED
@@ -16,7 +16,7 @@ export default {
16
16
  };
17
17
  },
18
18
  computed: {
19
- ...mapGetters(['shop']),
19
+ ...mapGetters(['shop', 'country', 'payment']),
20
20
  ...mapGetters('order', ['orderData', 'card']),
21
21
  isVisibleChargeMessage() {
22
22
  return this.isSuccessOrderCharge || this.isFailedOrderCharge;
@@ -44,7 +44,7 @@ export default {
44
44
  async proceedPayment(card) {
45
45
  try {
46
46
  this.clearFailedCharge();
47
- const data = { card, shop: this.shop._id };
47
+ const data = { card, shop: this.shop._id, country: this.country, payment: this.payment };
48
48
  await this.submitPayment(data);
49
49
  this.onOrderSucces();
50
50
  } catch (e) {
package/nuxt.config.js CHANGED
@@ -89,6 +89,11 @@ module.exports = (config, axios, { raygunClient, publicPath } = {}) => ({
89
89
  STATIC_URL: process.env.STATIC_URL
90
90
  },
91
91
  build: {
92
+ splitChunks: {
93
+ layouts: false,
94
+ pages: false,
95
+ commons: false
96
+ },
92
97
  publicPath: publicPath || '/client/',
93
98
  postcss: null,
94
99
  transpile: [
@@ -151,12 +156,23 @@ module.exports = (config, axios, { raygunClient, publicPath } = {}) => ({
151
156
  review_timestamp: { _text: review.createdAt },
152
157
  title: { _text: product.name },
153
158
  content: { _text: review.text },
159
+ pros: {
160
+ pro: (review.pro || '').split(/\n/).map(pro => ({ _text: pro }))
161
+ },
162
+ cons: {
163
+ con: (review.cons || '').split(/\n/).map(cons => ({ _text: cons }))
164
+ },
154
165
  review_url: {
155
166
  _attributes: {
156
167
  type: 'singleton'
157
168
  },
158
169
  _text: `${productUrl}#review-${review._id}`
159
170
  },
171
+ reviewer_images: {
172
+ reviewer_image: [{
173
+ url: { _text: review.image?.large }
174
+ }]
175
+ },
160
176
  ratings: {
161
177
  overall: {
162
178
  _attributes: {
@@ -169,50 +185,41 @@ module.exports = (config, axios, { raygunClient, publicPath } = {}) => ({
169
185
  products: {
170
186
  product: {
171
187
  product_ids: {
188
+ gtins: {
189
+ gtin: { _text: product.simpleProduct?.gtin }
190
+ },
191
+ skus: {
192
+ sku: { _text: product.simpleProduct?.SKU }
193
+ },
172
194
  brands: {
173
195
  brand: { _text: product.brand.name }
174
196
  },
175
- // mpns: {
176
- // mpn: { _text: '60101-10000' }
177
- // },
178
- // asins: {
179
- // asin: { _text: 'B07YMJ57MB' }
180
- // }
181
197
  },
182
198
  product_name: { _text: product.name },
183
199
  product_url: { _text: productUrl }
184
200
  }
185
- }
201
+ },
202
+ is_spam: { _text: 'false' }
186
203
  };
187
204
 
188
- if (product.simpleProduct?.gtin) {
189
- item.products.product.product_ids.gtins = {
190
- gtin: { _text: product.simpleProduct?.gtin }
191
- };
205
+ if (!product.simpleProduct?.gtin) {
206
+ delete item.products.product.product_ids.gtins;
192
207
  }
193
208
 
194
- if (product.simpleProduct?.SKU) {
195
- item.products.product.product_ids.skus = {
196
- sku: { _text: product.simpleProduct?.SKU }
197
- };
209
+ if (!product.simpleProduct?.SKU) {
210
+ delete item.products.product.product_ids.skus;
198
211
  }
199
212
 
200
- if (review.pro) {
201
- item.pros = {
202
- pro: [{ _text: review.pro }]
203
- };
213
+ if (!review.pro) {
214
+ delete item.pros;
204
215
  }
205
- if (review.cons) {
206
- item.cons = {
207
- con: [{ _text: review.cons }]
208
- };
216
+
217
+ if (!review.cons) {
218
+ delete item.cons;
209
219
  }
210
- if (review.image) {
211
- item.reviewer_images = {
212
- reviewer_image: [{
213
- url: { _text: review.image.large }
214
- }]
215
- };
220
+
221
+ if (!review.image) {
222
+ delete item.reviewer_images;
216
223
  }
217
224
  return item;
218
225
  })
@@ -273,11 +280,19 @@ module.exports = (config, axios, { raygunClient, publicPath } = {}) => ({
273
280
  'g:is_bundle': { _text: product.prePrint ? 'yes' : 'no' },
274
281
  'g:identifier_exists': sp.gtin ? 'yes' : 'no',
275
282
  'g:product_weight': { _text: `${product.weight} kg` },
276
- 'g:shipping_weight': { _text: `${((product.weight || 0) + (product.weight || 0) * 0.05).toFixed(3)} kg` }
283
+ 'g:shipping_weight': { _text: `${((product.weight || 0) + (product.weight || 0) * 0.05).toFixed(3)} kg` },
284
+ 'g:quantity': { _text: sp.quantityStock },
285
+ 'g:pickup_method': { _text: 'buy' },
286
+ 'g:pickup_sla': { _text: 'next day' }
277
287
  };
288
+
278
289
  if (sp.gtin) {
279
290
  info['g:gtin'] = { _text: sp.gtin || '' };
280
291
  }
292
+
293
+ if (sp.storeCode) {
294
+ info['g:store_code'] = { _text: sp.storeCode };
295
+ }
281
296
  if (product.volume) {
282
297
  if (product.volume.length) {
283
298
  info['g:shipping_length'] = { _text: `${product.volume.length} cm` };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lancom/shared",
3
- "version": "0.0.211",
3
+ "version": "0.0.213",
4
4
  "description": "lancom common scripts",
5
5
  "author": "e.tokovenko <e.tokovenko@gmail.com>",
6
6
  "repository": {
package/store/index.js CHANGED
@@ -6,6 +6,7 @@ const CLOSED_NOTIFICATION = 'lancom-closed-notification-1.0';
6
6
  export const state = () => ({
7
7
  country: null,
8
8
  currency: null,
9
+ payment: null,
9
10
  shop: {},
10
11
  menus: [],
11
12
  contacts: {},
@@ -23,6 +24,7 @@ export const getters = {
23
24
  currency: ({ currency }) => currency,
24
25
  currencies: ({ shop }) => (shop.countries || []).reduce((currencies, { country }) => [...currencies, country?.currency], []).filter(c => !!c),
25
26
  shop: ({ shop }) => shop || {},
27
+ payment: ({ payment }) => payment || {},
26
28
  menus: ({ menus }) => menus || [],
27
29
  topMenu: ({ menus }) => (menus || []).find(({ type }) => type === 'top'),
28
30
  footerMenus: ({ menus }) => (menus || []).filter(({ type }) => type === 'footer'),
@@ -52,6 +54,22 @@ export const actions = {
52
54
  const settings = await api.fetchClientSettings(shop._id, params);
53
55
  commit('setCountry', settings.country);
54
56
  commit('setCurrency', settings.currency);
57
+
58
+ debugger;
59
+ if (process.env.PINPAYMENT_PUBLISHABLE_API_KEY) {
60
+ commit('setPayment', {
61
+ type: 'pinpayment',
62
+ clientKey: process.env.PINPAYMENT_PUBLISHABLE_API_KEY
63
+ });
64
+ } else {
65
+ const countrySettings = shop.countries.find(c => c.country?._id === settings.country?._id) || { settings: [] };
66
+ const countrySetting = countrySettings.settings.find(s => !!s.settings.app.STRIPE_PUBLIC_KEY);
67
+ commit('setPayment', {
68
+ type: 'stripe',
69
+ clientKey: countrySetting.settings.app.STRIPE_PUBLIC_KEY
70
+ });
71
+ }
72
+
55
73
  // }
56
74
  try {
57
75
  if (req.headers.cookie) {
@@ -99,6 +117,9 @@ export const actions = {
99
117
  };
100
118
 
101
119
  export const mutations = {
120
+ setPayment(state, payment) {
121
+ state.payment = payment;
122
+ },
102
123
  setCountry(state, country) {
103
124
  state.country = country;
104
125
  },
package/store/order.js CHANGED
@@ -19,9 +19,10 @@ export const actions = {
19
19
  const response = await api.createOrder(order, shop);
20
20
  commit('setOrderData', response);
21
21
  },
22
- async submitPayment({ commit, state: { orderData } }, { card, shop }) {
22
+ async submitPayment({ commit, state: { orderData } }, { card, payment, country, shop }) {
23
23
  const { _id } = orderData || {};
24
- const response = await api.createOrderPayment(_id, card, shop);
24
+ debugger;
25
+ const response = await api.createOrderPayment(_id, { card, shop, country, payment });
25
26
  commit('setOrderData', response);
26
27
  return {};
27
28
  },