@lancom/shared 0.0.353 → 0.0.355

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 (26) hide show
  1. package/assets/js/utils/shop.js +4 -0
  2. package/components/checkout/cart/cart_entities_group/cart-entities-group.vue +1 -1
  3. package/components/checkout/cart/cart_entities_group/cart_entities_group_prints/cart_entities_group_print/cart-entities-group-print.vue +1 -1
  4. package/components/checkout/cart/cart_entities_group_table/cart_entities_group_tr/cart-entities-group-tr.vue +1 -1
  5. package/components/checkout/cart/cart_entity/cart_entity_prints/cart_entity_print/cart-entity-print.vue +1 -1
  6. package/components/checkout/order/order-payment-information/order-payment-information.vue +19 -7
  7. package/components/common/client_settings_stock_country/client-settings-stock-country.vue +5 -2
  8. package/components/common/payment/payment_card/googlepay/googlepay.scss +73 -0
  9. package/components/common/payment/payment_card/googlepay/googlepay.vue +185 -0
  10. package/components/common/payment/payment_card/payment-card.vue +7 -0
  11. package/components/editor/editor_workspace/editor_workspace_side/editor-workspace-side.vue +1 -2
  12. package/components/order/order_view/order_product_prints/order_product_print/order-product-print.vue +1 -1
  13. package/components/product/product_colors_selector/product-colors-selector.vue +3 -2
  14. package/components/product/wizard/wizard_print_layers/wizard_print_layer/wizard-print-layer.vue +1 -1
  15. package/components/product/wizard/wizard_print_text_or_logo/wizard-print-text-or-logo.vue +1 -1
  16. package/components/product/wizard/wizard_print_type/wizard_print_area_print_type/wizard-print-area-print-type.vue +1 -1
  17. package/components/quotes/quote_view/quote_product_prints/quote_product_print/quote-product-print.vue +1 -1
  18. package/feeds/google-shopping.js +4 -3
  19. package/mixins/meta-info.js +1 -1
  20. package/mixins/payment.js +1 -1
  21. package/mixins/print-layer.js +2 -2
  22. package/mixins/product-view.js +31 -14
  23. package/package.json +1 -1
  24. package/store/cart.js +0 -2
  25. package/store/index.js +4 -1
  26. package/store/product.js +23 -2
@@ -4,6 +4,10 @@ export function getShopCountrySettings(shop, country) {
4
4
 
5
5
  return {
6
6
  ...shop.settings,
7
+ contacts: {
8
+ ...(shop.settings.app || {}),
9
+ ...settingsValues(countrySetting?.settings?.app)
10
+ },
7
11
  contacts: {
8
12
  ...shop.settings.contacts,
9
13
  ...settingsValues(countrySetting?.settings?.contacts)
@@ -50,7 +50,7 @@
50
50
  :key="`${entity.guid}_${index}`"
51
51
  class="lc_regular12 lc_grey1">
52
52
  <div>
53
- {{ print.printArea.name }} | {{ print.printSize.name }} | {{ print.printType.name }}
53
+ {{ print.printArea.name }} | {{ print.printSize.name }} | {{ print.printType ? print.printType.name : '' }}
54
54
  </div>
55
55
  </div>
56
56
  </div>
@@ -1,7 +1,7 @@
1
1
  <template>
2
2
  <tr>
3
3
  <td class="lc_body-small">
4
- {{ print.printType.name }}
4
+ {{ print.printType ? print.printType.name : '' }}
5
5
  </td>
6
6
  <td class="lc_body-small">
7
7
  {{ print.printArea.name }}
@@ -46,7 +46,7 @@
46
46
  :key="`${entity.guid}_${index}`"
47
47
  class="lc_regular12 lc_grey1">
48
48
  <div>
49
- {{ print.printArea.name }} | {{ print.printSize.name }} | {{ print.printType.name }}
49
+ {{ print.printArea.name }} | {{ print.printSize.name }} | {{ print.printType ? print.printType.name : '' }}
50
50
  </div>
51
51
  </div>
52
52
  </div>
@@ -3,7 +3,7 @@
3
3
  <tr>
4
4
  <td class="lc_body-small">
5
5
  <span class="hidden-md-and-up">Print Type</span>
6
- {{ print.printType.name }}
6
+ {{ print.printType ? print.printType.name : '' }}
7
7
  </td>
8
8
  <td class="lc_body-small">
9
9
  <span class="hidden-md-and-up">Location</span>
@@ -11,23 +11,31 @@
11
11
  <div class="form-row OrderPaymentInformation__form">
12
12
  <label
13
13
  class="form-label OrderPaymentInformation__checkbox"
14
- @click="updatePaymentType(false)">
15
- <checked-icon :checked="!isDepositPayment" />
14
+ @click="updatePaymentType('card')">
15
+ <checked-icon :checked="paymentMethod === 'card'" />
16
16
  <span class="lc_regular12 lc__grey1 OrderPaymentInformation__checkbox-label">
17
17
  Credit Card
18
18
  </span>
19
19
  </label>
20
20
  <label
21
21
  class="form-label OrderPaymentInformation__checkbox"
22
- @click="updatePaymentType(true)">
23
- <checked-icon :checked="isDepositPayment" />
22
+ @click="updatePaymentType('deposit')">
23
+ <checked-icon :checked="paymentMethod === 'deposit'" />
24
24
  <span class="lc_regular12 lc__grey1 OrderPaymentInformation__checkbox-label">
25
25
  Bank Transfer
26
26
  </span>
27
27
  </label>
28
+ <label
29
+ class="form-label OrderPaymentInformation__checkbox"
30
+ @click="updatePaymentType('google')">
31
+ <checked-icon :checked="paymentMethod === 'google'" />
32
+ <span class="lc_regular12 lc__grey1 OrderPaymentInformation__checkbox-label">
33
+ Google Pay
34
+ </span>
35
+ </label>
28
36
  </div>
29
37
  <div
30
- v-if="isDepositPayment"
38
+ v-if="paymentMethod === 'deposit'"
31
39
  class="OrderPaymentInformation__direct-deposit">
32
40
  <div
33
41
  class="OrderPaymentInformation__direct-deposit-info"
@@ -60,6 +68,8 @@
60
68
  <payment-card
61
69
  v-if="orderData"
62
70
  ref="paymentCart"
71
+ :key="paymentMethod"
72
+ :google="paymentMethod === 'google'"
63
73
  :amount="cartPricing.totalPrice"
64
74
  :order="orderData"
65
75
  @inited="initedCard">
@@ -108,6 +118,7 @@ export default {
108
118
  creating: false,
109
119
  submitting: false,
110
120
  loadingCard: true,
121
+ paymentMethod: this.order.paymentMethod || ORDER_PAYMENT_METHOD.CARD,
111
122
  isDepositPayment: this.order.paymentMethod === ORDER_PAYMENT_METHOD.DEPOSIT
112
123
  };
113
124
  },
@@ -162,8 +173,9 @@ export default {
162
173
  }
163
174
  }
164
175
  },
165
- updatePaymentType(isDeposit) {
166
- this.isDepositPayment = isDeposit;
176
+ updatePaymentType(paymentMethod) {
177
+ this.isDepositPayment = paymentMethod === ORDER_PAYMENT_METHOD.DEPOSIT;
178
+ this.paymentMethod = paymentMethod;
167
179
  this.errorMessage = null;
168
180
  },
169
181
  depositInfo(info) {
@@ -16,7 +16,7 @@
16
16
  </template>
17
17
 
18
18
  <script>
19
- import { mapGetters } from 'vuex';
19
+ import { mapGetters, mapMutations } from 'vuex';
20
20
 
21
21
  const Cookie = process.client ? require('js-cookie') : undefined;
22
22
 
@@ -44,9 +44,12 @@ export default {
44
44
  }
45
45
  },
46
46
  methods: {
47
+ ...mapMutations([
48
+ 'setStockCountry'
49
+ ]),
47
50
  selectStockCountry(stockCountry) {
48
51
  this.saveStockCountry(stockCountry);
49
- window.location.reload();
52
+ this.setStockCountry(stockCountry);
50
53
  },
51
54
  saveStockCountry(stockCountry) {
52
55
  const value = (stockCountry && stockCountry.isoCode !== 'world') ? stockCountry?._id : null
@@ -0,0 +1,73 @@
1
+ @import "@/assets/scss/ui_kit";
2
+ @import "@/assets/scss/variables";
3
+
4
+ .example {
5
+ margin: 5px;
6
+ display: flex;
7
+ flex-direction: row;
8
+ }
9
+
10
+ .example > .title {
11
+ width: 250px;
12
+ align-items: center;
13
+ display: inherit;
14
+ }
15
+
16
+ .example > .demo {
17
+ flex: 1 0 0;
18
+ }
19
+
20
+ .example > .demo > * {
21
+ margin: 1px;
22
+ }
23
+
24
+ .Payment {
25
+ &__wrapper {
26
+ .pin-form-field {
27
+ // @extend .form-field;
28
+ // @extend .labelless;
29
+ border-radius: 0px;
30
+ background-color: #F4F4F4;
31
+ }
32
+ }
33
+ &__field-container {
34
+ width: 100%;
35
+ }
36
+ &__message {
37
+ padding: 50px 140px;
38
+ }
39
+ &__content {
40
+ position: relative;
41
+ min-height: 100px;
42
+ }
43
+ &__fileds-spinner {
44
+ background-color: white;
45
+ }
46
+ &__terms {
47
+ margin-top: 20px;
48
+ }
49
+ &__label-with-checkbox {
50
+ display: flex !important;
51
+ align-items: center;
52
+ margin-bottom: 3px !important;
53
+ a {
54
+ color: $green;
55
+ }
56
+ }
57
+ }
58
+
59
+ .form-row--cols {
60
+ @media (max-width: $bp-extra-small-max) {
61
+ flex-direction: column;
62
+ }
63
+ .col-half {
64
+ @media (max-width: $bp-extra-small-max) {
65
+ flex-basis: 100%;
66
+ width: 100%;
67
+ margin-left: 0 !important;
68
+ &:nth-child(2) {
69
+ margin-top: 20px;
70
+ }
71
+ }
72
+ }
73
+ }
@@ -0,0 +1,185 @@
1
+ <template>
2
+ <div class="Payment__wrapper">
3
+ <div v-if="(hasSpinner && processing) || loading">
4
+ <spinner />
5
+ </div>
6
+ <div
7
+ :style="{
8
+ opacity: loading ? 0 : 1
9
+ }">
10
+ <div
11
+ v-if="amount"
12
+ class="form-row">
13
+ <label
14
+ for="payment-amount"
15
+ class="form-label">
16
+ Amount to Pay
17
+ </label>
18
+ <input
19
+ id="payment-amount"
20
+ :value="`${amount} AUD`"
21
+ name="payment-amount"
22
+ placeholder="payment-amount"
23
+ disabled
24
+ type="text"
25
+ class="form-field labelless" />
26
+ </div>
27
+ <div class="examples">
28
+ <div>
29
+ <div class="example">
30
+ <div class="demo">
31
+ <google-pay-button
32
+ v-if="!loading"
33
+ environment="TEST"
34
+ button-type="plain"
35
+ button-color="black"
36
+ v-bind:paymentRequest.prop="{
37
+ apiVersion: 2,
38
+ apiVersionMinor: 0,
39
+ allowedPaymentMethods: [
40
+ {
41
+ type: 'CARD',
42
+ parameters: {
43
+ allowedAuthMethods: ['PAN_ONLY', 'CRYPTOGRAM_3DS'],
44
+ allowedCardNetworks: ['MASTERCARD', 'VISA'],
45
+ },
46
+ tokenizationSpecification: {
47
+ type: 'PAYMENT_GATEWAY',
48
+ parameters: {
49
+ gateway: 'pinpayments',
50
+ gatewayMerchantId: app.PAYMENT_GOOGLE_GATEWAY,
51
+ }
52
+ },
53
+ },
54
+ ],
55
+ merchantInfo: {
56
+ merchantId: app.PAYMENT_GOOGLE_MERCHANT_ID,
57
+ merchantName: app.PAYMENT_GOOGLE_MERCHANT_NAME,
58
+ },
59
+ transactionInfo: {
60
+ totalPriceStatus: 'FINAL',
61
+ totalPriceLabel: 'Total',
62
+ totalPrice: amountString,
63
+ currencyCode: currencyCode,
64
+ countryCode: countryCode
65
+ },
66
+ }"
67
+ @loadpaymentdata="onLoadPaymentData"
68
+ @error="onError" />
69
+ </div>
70
+ </div>
71
+ </div>
72
+ </div>
73
+ </div>
74
+ <slot v-if="!loading" name="controls" v-bind="{ processing }"></slot>
75
+ </div>
76
+ </template>
77
+
78
+ <script>
79
+ import { mapGetters } from 'vuex';
80
+ import '@google-pay/button-element';
81
+
82
+ let timer = null;
83
+ let googlepayStartLoaded = false;
84
+
85
+ export default {
86
+ name: 'Googlepay',
87
+ props: {
88
+ order: {
89
+ type: Object,
90
+ required: true
91
+ },
92
+ amount: {
93
+ type: Number
94
+ },
95
+ hasSpinner: {
96
+ type: Boolean,
97
+ default: true
98
+ }
99
+ },
100
+ data() {
101
+ return {
102
+ paymentData: null,
103
+ paymentError: null,
104
+ processing: false,
105
+ loading: false,
106
+ fields: null
107
+ };
108
+ },
109
+ async mounted() {
110
+ this.loading = true;
111
+ await this.loadGooglepay();
112
+ this.loading = false;
113
+ },
114
+ destroyed() {
115
+ clearInterval(timer);
116
+ },
117
+ computed: {
118
+ ...mapGetters(['country', 'currency', 'app']),
119
+ amountString() {
120
+ return `${this.amount.toFixed(2)}`;
121
+ },
122
+ currencyCode() {
123
+ return this.currency?.isoCode || 'AUSD';
124
+ },
125
+ countryCode() {
126
+ return this.country?.isoCode || 'AU';
127
+ }
128
+ },
129
+ methods: {
130
+ onLoadPaymentData(event) {
131
+ const token = JSON.parse(event.detail.paymentMethodData.tokenizationData.token);
132
+ this.paymentData = { google: true, token }
133
+ },
134
+ onError(event) {
135
+ this.paymentError = event.error;
136
+ console.log('this.paymentError: ', this.paymentError);
137
+ },
138
+ tokenize() {
139
+ this.processing = true;
140
+ return new Promise((resolve, reject) => {
141
+ if (this.paymentError || !this.paymentData) {
142
+ reject(!this.paymentData ? 'Payment Failed. Need to choose card' : 'Payment Failed')
143
+ } else {
144
+ resolve(this.paymentData);
145
+ }
146
+ this.processing = false;
147
+ });
148
+ },
149
+ async loadGooglepay() {
150
+ if (process.browser) {
151
+ await (new Promise((resolve, reject) => {
152
+ if (!googlepayStartLoaded) {
153
+ googlepayStartLoaded = true;
154
+ resolve();
155
+ googlepayStartLoaded = false;
156
+ // let domElement = document.createElement('script');
157
+ // domElement.type = "text/javascript";
158
+ // domElement.setAttribute('src', 'https://cdn.pinpayments.com/pin.hosted_fields.v1.js');
159
+ // domElement.onload = () => {
160
+ // resolve();
161
+ // };
162
+ // domElement.onerror = () => {
163
+ // setTimeout(() => this.loadPinpayments(), 1000);
164
+ // };
165
+ // document.body.appendChild(domElement);
166
+ } else {
167
+ let repeated = 0;
168
+ timer = setInterval(() => {
169
+ if (!googlepayStartLoaded || repeated++ > 40) {
170
+ clearInterval(timer);
171
+ resolve();
172
+ }
173
+ }, 500);
174
+ }
175
+ }));
176
+ }
177
+ }
178
+ }
179
+ };
180
+ </script>
181
+
182
+
183
+ <style lang="scss" scoped>
184
+ @import 'googlepay.scss';
185
+ </style>
@@ -17,6 +17,7 @@ import { mapGetters } from 'vuex';
17
17
  export default {
18
18
  name: 'PaymentCard',
19
19
  components: {
20
+ Googlepay: () => import('./googlepay/googlepay'),
20
21
  Pinpayment: () => import('./pinpayment/pinpayment'),
21
22
  Stripe: () => import('./stripe_card/stripe-card'),
22
23
  StripePayment: () => import('./stripe_payment/stripe-payment')
@@ -28,11 +29,17 @@ export default {
28
29
  },
29
30
  amount: {
30
31
  type: Number
32
+ },
33
+ google: {
34
+ type: Boolean
31
35
  }
32
36
  },
33
37
  computed: {
34
38
  ...mapGetters(['payment']),
35
39
  cardComponent() {
40
+ if (this.google) {
41
+ return 'googlepay';
42
+ }
36
43
  return this.payment?.type || 'stripe-payment';
37
44
  }
38
45
  },
@@ -203,8 +203,7 @@ export default {
203
203
  return this.images.find(i => i.types?.includes('wireframe') && i.types?.includes(this.side));
204
204
  },
205
205
  onpressImage() {
206
- console.log('this.images: ', this.images);
207
- return this.product.images?.find(i => i.types?.includes('on_press'));
206
+ return this.product.images?.find(i => i.types?.includes('on_press') && i.color === this.editableColor?._id);
208
207
  },
209
208
  sideEditableLayers() {
210
209
  return this.editableLayers.filter(l => l.sideId === this.side);
@@ -3,7 +3,7 @@
3
3
  <tr>
4
4
  <td class="lc_body-small">
5
5
  <span :class="responsive ? 'hidden-md-and-up' : 'hidden'">Print Type</span>
6
- {{ print.printType.name }}
6
+ {{ print.printType ? print.printType.name : '' }}
7
7
  </td>
8
8
  <td class="lc_body-small">
9
9
  <span :class="responsive ? 'hidden-md-and-up' : 'hidden'">Location</span>
@@ -82,6 +82,7 @@
82
82
  </div>
83
83
  </div>
84
84
  <products-size-selector-color
85
+ :key="productDetailsKey"
85
86
  :with-gst="inclGSTFinal"
86
87
  class="ProductColorsSelector__section"
87
88
  :class="{
@@ -131,8 +132,8 @@ export default {
131
132
  }
132
133
  },
133
134
  computed: {
134
- ...mapGetters(['taxName']),
135
- ...mapGetters('product', ['editableColor', 'availableColors', 'visibleSteps', 'hasLayers', 'isPrintPricing', 'priceIncludeGST']),
135
+ ...mapGetters(['stockCountry', 'taxName']),
136
+ ...mapGetters('product', ['productDetailsKey', 'editableColor', 'availableColors', 'visibleSteps', 'hasLayers', 'isPrintPricing', 'priceIncludeGST']),
136
137
  selectedColor: {
137
138
  get() {
138
139
  return this.editableColor;
@@ -17,7 +17,7 @@
17
17
  <div class="lc_regular14 hidden-sm-and-up">
18
18
  Print type
19
19
  </div>
20
- {{ layerPrintType.name }}
20
+ {{ layerPrintType ? layerPrintType.name : '-' }}
21
21
  </td>
22
22
  <td>
23
23
  <div class="lc_regular14 hidden-sm-and-up">
@@ -107,7 +107,7 @@ export default {
107
107
  printArea: editablePrintArea._id,
108
108
  printSize: selectedPrintArea?._id,
109
109
  side: editablePrintArea.side,
110
- printType: selectedPrintType._id
110
+ printType: selectedPrintType?._id
111
111
  }
112
112
  };
113
113
  if (layer.type === 'text') {
@@ -95,7 +95,7 @@ export default {
95
95
  methods: {
96
96
  ...mapMutations('product', ['setSelectedPrintTypes']),
97
97
  isSelectedType(type) {
98
- return this.selectedPrintType && this.selectedPrintType._id === type._id;
98
+ return this.selectedPrintType && this.selectedPrintType?._id === type._id;
99
99
  },
100
100
  selectPrintType(type) {
101
101
  this.setSelectedPrintTypes({ printArea: this.editablePrintArea._id, type });
@@ -3,7 +3,7 @@
3
3
  <tr>
4
4
  <td class="lc_body-small">
5
5
  <span class="hidden-md-and-up">Print Type</span>
6
- {{ print.printType.name }}
6
+ {{ print.printType ? print.printType.name : '' }}
7
7
  </td>
8
8
  <td class="lc_body-small">
9
9
  <span class="hidden-md-and-up">Location</span>
@@ -66,9 +66,10 @@ async function googleShoppingFeed(axios, config, availableStores, country, isEdi
66
66
 
67
67
  const productWeight = +((product.weight || 0) * (sp.multipackQty || 1)).toFixed(3);
68
68
  const info = {
69
- title: { _text: sp.title || title },
70
- description: { _text: sp.description || description },
69
+ 'g:title': { _text: sp.title || title },
70
+ 'g:description': { _text: sp.description || description },
71
71
  link: { _text: link },
72
+ 'g:canonical_link': { _text: link.split('?')[0] },
72
73
  'g:id': { _text: sp.SKU },
73
74
  'g:item_group_id': { _text: product.SKU },
74
75
  'g:size': { _text: sp.size.name },
@@ -161,7 +162,7 @@ async function googleShoppingFeed(axios, config, availableStores, country, isEdi
161
162
 
162
163
  for (let label = 0; label <= 4; label++) {
163
164
  if (product[`feedCustomLabel${label}`]) {
164
- info[`custom_label_${label}`] = { _text: product[`feedCustomLabel${label}`] };
165
+ info[`g:custom_label_${label}`] = { _text: product[`feedCustomLabel${label}`] };
165
166
  }
166
167
  }
167
168
 
@@ -39,7 +39,7 @@ const metaInfo = {
39
39
  head() {
40
40
  const hasQueryParams = Object
41
41
  .keys(this.$route.query || {})
42
- .filter(key => !['color', 'store'].includes(`${key || ''}`.toLowerCase()))
42
+ .filter(key => !['color', 'store','price'].includes(`${key || ''}`.toLowerCase()))
43
43
  .length > 0;
44
44
 
45
45
  const { short_text: shortText, image, meta = {} } = this.routeInfo || {};
package/mixins/payment.js CHANGED
@@ -38,7 +38,7 @@ export default {
38
38
  ...mapMutations('layers', ['resetLayers']),
39
39
  handleErrors(err) {
40
40
  // err.messages.forEach(({ message }) => this.$toastr.e(message));
41
- const defaultMessage = 'Payment error';
41
+ const defaultMessage = typeof err === 'string' ? err : 'Payment error';
42
42
  this.errorMessage = (err.messages ? err.messages.map(({ message }) => message).join(', ') : (err.error_description)) || err.message || defaultMessage;
43
43
  },
44
44
  async proceedPayment(card) {
@@ -38,8 +38,8 @@ export default {
38
38
  return this.layerPrintSizes.find(({ _id }) => _id === this.layer.printSize);
39
39
  },
40
40
  layerPrintPricing() {
41
- const printArea = this.layerPrintType.printAreas.find(({ printSizes }) => printSizes.map(({ _id }) => _id).includes(this.layer.printSize)) || this.layerPrintType.printAreas[0];
42
- return printArea.printCost;
41
+ const printArea = this.layerPrintType?.printAreas.find(({ printSizes }) => printSizes.map(({ _id }) => _id).includes(this.layer.printSize)) || this.layerPrintType?.printAreas[0];
42
+ return printArea?.printCost;
43
43
  }
44
44
  }
45
45
  };
@@ -80,9 +80,17 @@ export default (IS_PRODUCT_PRESET_PRINT_PRICING, isEditor = false) => ({
80
80
  preSetPrintPricing: false
81
81
  };
82
82
  },
83
+ watch: {
84
+ async stockCountryId(prev, curr) {
85
+ await this.loadProductStockDetails();
86
+ }
87
+ },
83
88
  computed: {
84
89
  ...mapGetters(['shop', 'gstTax', 'country', 'stockCountry', 'currency']),
85
90
  ...mapGetters('product', ['product', 'simpleProducts', 'productDetails', 'editableColor', 'images', 'preSetPrints', 'editorSize', 'printsPrice']),
91
+ stockCountryId() {
92
+ return this.stockCountry?._id || null;
93
+ },
86
94
  pageItemImage() {
87
95
  return this.mainProductImageSrc;
88
96
  },
@@ -115,21 +123,12 @@ export default (IS_PRODUCT_PRESET_PRINT_PRICING, isEditor = false) => ({
115
123
  this.fillBreadcrumbs();
116
124
  },
117
125
  async mounted() {
118
- const { slug } = this.$route.params;
119
- const { color, colour, multipack } = this.$route.query;
120
- const data = {
121
- shop: this.shop._id,
122
- slug,
123
- country: this.country?._id,
124
- stockCountry: this.stockCountry?._id,
125
- currency: this.currency?._id,
126
- defaultColor: color || colour
127
- };
128
126
  if (!this.product) {
129
- await this.fetchProduct(data);
127
+ const query = this.getProductQuery();
128
+ await this.fetchProduct(query);
130
129
  }
131
130
 
132
- await this.fetchProductDetails(data);
131
+ await this.loadProductStockDetails();
133
132
 
134
133
  try {
135
134
  if (this.preSetPrints?.length) {
@@ -171,7 +170,7 @@ export default (IS_PRODUCT_PRESET_PRINT_PRICING, isEditor = false) => ({
171
170
  }
172
171
 
173
172
  this.fillBreadcrumbs();
174
-
173
+ const { multipack } = this.$route.query;
175
174
  if (multipack) {
176
175
  const [SKU, qty] = multipack.split('-multipack-');
177
176
  const simpleProduct = this.simpleProducts.find(sp => sp.SKU === SKU);
@@ -192,9 +191,27 @@ export default (IS_PRODUCT_PRESET_PRINT_PRICING, isEditor = false) => ({
192
191
  this.clearProduct();
193
192
  },
194
193
  methods: {
195
- ...mapActions(['fetchProduct', 'fetchProductDetails', 'selectColor']),
194
+ ...mapActions(['fetchProduct', 'fetchProductDetails', 'fetchProductStockDetails', 'selectColor']),
196
195
  ...mapMutations(['clearProduct', 'clearTemplate', 'addTemplateLayer', 'setSimpleProductAmount', 'setPriceIncludeGST']),
197
196
  staticLink,
197
+ getProductQuery() {
198
+ const { slug } = this.$route.params;
199
+ const { color, colour } = this.$route.query;
200
+ const data = {
201
+ shop: this.shop._id,
202
+ slug,
203
+ country: this.country?._id,
204
+ stockCountry: this.stockCountry?._id,
205
+ currency: this.currency?._id,
206
+ defaultColor: color || colour
207
+ };
208
+
209
+ return data;
210
+ },
211
+ loadProductStockDetails() {
212
+ const query = this.getProductQuery();
213
+ this.fetchProductStockDetails(query);
214
+ },
198
215
  goToInfoTab(tab) {
199
216
  this.$refs.infoTabs.selectedTab = tab;
200
217
  const { $el } = this.$refs.infoTabs;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lancom/shared",
3
- "version": "0.0.353",
3
+ "version": "0.0.355",
4
4
  "description": "lancom common scripts",
5
5
  "author": "e.tokovenko <e.tokovenko@gmail.com>",
6
6
  "repository": {
package/store/cart.js CHANGED
@@ -165,7 +165,6 @@ export const actions = {
165
165
  try {
166
166
  commit('setCartPricingCalculating', true);
167
167
  const response = await api.calculateProductPrice(payload, shop._id);
168
- console.log('response: ', response);
169
168
  commit('setCartPricing', response);
170
169
  commit('setCartPricingError', null);
171
170
  } catch (e) {
@@ -237,7 +236,6 @@ export const mutations = {
237
236
  state.coupon = coupon;
238
237
  },
239
238
  setCartPricing(state, price) {
240
- console.log('setCartPricing: ', price);
241
239
  state.cartPricing = price;
242
240
  },
243
241
  setCartPricingCalculating(state, calculating) {
package/store/index.js CHANGED
@@ -13,6 +13,7 @@ export const state = () => ({
13
13
  payment: null,
14
14
  shop: {},
15
15
  menus: [],
16
+ app: {},
16
17
  contacts: {},
17
18
  orderInfo: {},
18
19
  pricing: {},
@@ -23,6 +24,7 @@ export const state = () => ({
23
24
  });
24
25
 
25
26
  export const getters = {
27
+ app: ({ app }) => app,
26
28
  stockCountry: ({ stockCountry }) => stockCountry,
27
29
  country: ({ country }) => country,
28
30
  countries: ({ shop }) => (shop.countries || []).map(({ country }) => country).filter(c => !!c),
@@ -147,7 +149,8 @@ export const mutations = {
147
149
  setCurrency(state, currency) {
148
150
  state.currency = currency;
149
151
  },
150
- setSettings(state, { contacts, notificationBar, discountPopup, order, depositInfo, pricing }) {
152
+ setSettings(state, { contacts, notificationBar, discountPopup, order, depositInfo, pricing, app }) {
153
+ state.app = app;
151
154
  state.contacts = contacts;
152
155
  state.orderInfo = order;
153
156
  state.notificationBar = notificationBar;
package/store/product.js CHANGED
@@ -13,6 +13,7 @@ export const state = () => ({
13
13
  multipack: null,
14
14
  calculatingPrice: false,
15
15
  loadingProductDetails: false,
16
+ productDetailsKey: Date.now(),
16
17
  images: [],
17
18
  priceIncludeGST: false,
18
19
  product: null,
@@ -51,6 +52,7 @@ export const state = () => ({
51
52
  });
52
53
 
53
54
  export const getters = {
55
+ productDetailsKey: ({ productDetailsKey }) => productDetailsKey,
54
56
  loadingProductDetails: ({ loadingProductDetails }) => loadingProductDetails,
55
57
  multipack: ({ multipack }) => multipack,
56
58
  calculatingPrice: ({ calculatingPrice }) => calculatingPrice,
@@ -187,7 +189,8 @@ export const actions = {
187
189
  commit('setLoadingProductDetails', false);
188
190
 
189
191
  const catalogFrontColorId = getColorOfDefaultCatalogFrontImage(state.product);
190
- const editableColor = state.availableColors.find(c => c.alias === defaultColor) ||
192
+ const editableColor = state.availableColors.find(c => c._id === state.editableColor?._id) ||
193
+ state.availableColors.find(c => c.alias === defaultColor) ||
191
194
  state.availableColors.find(c => c._id === catalogFrontColorId) ||
192
195
  state.availableColors[0];
193
196
  commit('setEditableColor', editableColor);
@@ -205,6 +208,13 @@ export const actions = {
205
208
  images = [...imagesGroups.values()].reduce((images, group) => [...images, ...group], []);
206
209
  commit('setImages', images);
207
210
  },
211
+ async fetchProductStockDetails({ commit }, { shop, slug, country, stockCountry, currency }) {
212
+ const params = { country, currency, stockCountry };
213
+ commit('setLoadingProductDetails', true);
214
+ const response = await api.fetchProductDetails(shop, slug, params);
215
+ commit('setProductStockDetails', response);
216
+ commit('setLoadingProductDetails', false);
217
+ },
208
218
  async fetchPrintTypes({ commit }, { shop }) {
209
219
  const response = await api.fetchPrintTypes(shop);
210
220
  commit('setPrintTypes', response);
@@ -297,7 +307,7 @@ export const mutations = {
297
307
  setProductDetails(state, simpleProducts) {
298
308
  const { preSetPrints } = state;
299
309
  const [preSetPrint] = preSetPrints || [];
300
- simpleProducts = simpleProducts.filter(sp => !preSetPrint || (preSetPrint.colors || []).includes(sp.color._id) )
310
+ simpleProducts = simpleProducts.filter(sp => !preSetPrint || (preSetPrint.colors || []).includes(sp.color._id) );
301
311
  state.productDetails = { simpleProducts };
302
312
  const availableSizes = [];
303
313
  const sizesPerColor = simpleProducts.reduce((map, { color, size }) => {
@@ -321,6 +331,17 @@ export const mutations = {
321
331
  }
322
332
  }
323
333
  state.availableColors = sortByName(availableColors);
334
+ state.productDetailsKey = Date.now();
335
+ },
336
+ setProductStockDetails(state, simpleProducts) {
337
+ state.productDetails?.simpleProducts?.forEach(sp => {
338
+ const sp2 = simpleProducts.find(simpleProduct => simpleProduct.SKU === sp.SKU);
339
+ Vue.set(sp, 'quantityStock', sp2?.quantityStock || 0);
340
+ });
341
+ state.template?.simpleProducts?.forEach(sp => {
342
+ const sp2 = simpleProducts.find(simpleProduct => simpleProduct.SKU === sp.SKU);
343
+ Vue.set(sp, 'quantityStock', sp2?.quantityStock || 0);
344
+ });
324
345
  },
325
346
  clearProduct(state) {
326
347
  state.product = null;