@lancom/shared 0.0.353 → 0.0.354

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 (19) hide show
  1. package/components/checkout/cart/cart_entities_group/cart-entities-group.vue +1 -1
  2. package/components/checkout/cart/cart_entities_group/cart_entities_group_prints/cart_entities_group_print/cart-entities-group-print.vue +1 -1
  3. package/components/checkout/cart/cart_entities_group_table/cart_entities_group_tr/cart-entities-group-tr.vue +1 -1
  4. package/components/checkout/cart/cart_entity/cart_entity_prints/cart_entity_print/cart-entity-print.vue +1 -1
  5. package/components/common/client_settings_stock_country/client-settings-stock-country.vue +5 -2
  6. package/components/editor/editor_workspace/editor_workspace_side/editor-workspace-side.vue +1 -2
  7. package/components/order/order_view/order_product_prints/order_product_print/order-product-print.vue +1 -1
  8. package/components/product/product_colors_selector/product-colors-selector.vue +3 -2
  9. package/components/product/wizard/wizard_print_layers/wizard_print_layer/wizard-print-layer.vue +1 -1
  10. package/components/product/wizard/wizard_print_text_or_logo/wizard-print-text-or-logo.vue +1 -1
  11. package/components/product/wizard/wizard_print_type/wizard_print_area_print_type/wizard-print-area-print-type.vue +1 -1
  12. package/components/quotes/quote_view/quote_product_prints/quote_product_print/quote-product-print.vue +1 -1
  13. package/feeds/google-shopping.js +4 -3
  14. package/mixins/meta-info.js +1 -1
  15. package/mixins/print-layer.js +2 -2
  16. package/mixins/product-view.js +31 -14
  17. package/package.json +1 -1
  18. package/store/cart.js +0 -2
  19. package/store/product.js +23 -2
@@ -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>
@@ -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
@@ -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 || {};
@@ -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.354",
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/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;