@lancom/shared 0.0.162 → 0.0.164

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.
@@ -46,6 +46,34 @@ const gtm = {
46
46
  quantity: amount
47
47
  }))
48
48
  });
49
+ },
50
+ purchase(order) {
51
+ const event = {
52
+ event: 'purchase',
53
+ transaction_id: order.code,
54
+ value: order.total,
55
+ currency: 'AUD',
56
+ coupon: order.couponCode,
57
+ shipping: order.shippingTotal,
58
+ tax: +(order.totalGST - order.total).toFixed(2),
59
+ items: order.products.reduce((products, { product, simpleProducts }) => {
60
+ return [
61
+ ...products,
62
+ ...simpleProducts
63
+ .filter(({ amount }) => amount > 0)
64
+ .map(({ SKU, productCost, amount, color, size }) => ({
65
+ item_id: SKU,
66
+ item_name: `${product.name} ${color?.name || ''} ${size?.name || ''}`.trim(),
67
+ item_brand: product.brand.name,
68
+ price: productCost,
69
+ currency: 'AUD',
70
+ quantity: amount
71
+ }))
72
+ ];
73
+ }, [])
74
+ };
75
+ console.log('purchase: ', event);
76
+ gtm.push(event);
49
77
  }
50
78
  };
51
79
 
@@ -54,6 +54,7 @@
54
54
  {{ errorMessage }}
55
55
  </div>
56
56
  <payment-cart
57
+ v-if="cartPricing"
57
58
  ref="paymentCart"
58
59
  :amount="cartPricing.totalPrice"
59
60
  :payment-data="order.shippingAddress">
@@ -252,21 +252,7 @@ export default {
252
252
  }
253
253
  },
254
254
  sendConversionData() {
255
- if (process.env.IS_PROD) {
256
- gtm.push({
257
- id: this.orderData._id,
258
- total: this.orderData.price.totalPrice,
259
- tax: this.orderData.price.tax.totalPrice,
260
- shipping: this.orderData.postcode,
261
- products: this.orderData.products.map(product => ({
262
- sku: product.SKU,
263
- name: product.name,
264
- category: product.brand,
265
- price: product.pricing[0].price,
266
- quantity: product.amount
267
- }))
268
- });
269
- }
255
+ gtm.purchase(this.orderData);
270
256
  },
271
257
  back() {
272
258
  /*
@@ -1,4 +1,4 @@
1
- import { mapGetters, mapActions } from 'vuex';
1
+ import { mapGetters, mapActions, mapMutations } from 'vuex';
2
2
  import api from '@lancom/shared/assets/js/api';
3
3
  import { price, shortDate, tax } from '@lancom/shared/assets/js/utils/filters';
4
4
  import { convertQuoteToOrder } from '@lancom/shared/assets/js/utils/quote';
@@ -26,6 +26,7 @@ export default {
26
26
  },
27
27
  methods: {
28
28
  ...mapActions('quote', ['selectOption', 'clear']),
29
+ ...mapMutations('quote', ['setOrder']),
29
30
  optionGst(option) {
30
31
  return tax(option.total, this.gstTax) - option.total;
31
32
  },
@@ -33,6 +34,7 @@ export default {
33
34
  try {
34
35
  this.processing = true;
35
36
  this.order = await this.createOrder(option);
37
+ this.setOrder(this.order);
36
38
  this.clear();
37
39
  } catch (e) {
38
40
  const { message } = (e.response && e.response.data) || e;
package/mixins/payment.js CHANGED
@@ -63,31 +63,7 @@ export default {
63
63
  }
64
64
  },
65
65
  sendConversionData() {
66
- const event = {
67
- event: 'purchase',
68
- transaction_id: this.orderData.code,
69
- value: this.orderData.total,
70
- currency: 'AUD',
71
- coupon: this.orderData.couponCode,
72
- shipping: this.orderData.shippingTotal,
73
- tax: this.orderData.totalGST - this.orderData.total,
74
- items: this.orderData.products.reduce((products, { product, simpleProducts }) => {
75
- return [
76
- ...products,
77
- ...simpleProducts
78
- .filter(({ amount }) => amount > 0)
79
- .map(({ SKU, productCost, amount }) => ({
80
- item_id: SKU,
81
- item_name: product.name,
82
- item_brand: product.brand.name,
83
- price: productCost,
84
- currency: 'AUD',
85
- quantity: amount
86
- }))
87
- ];
88
- }, [])
89
- };
90
- gtm.push(event);
66
+ gtm.purchase(this.orderData);
91
67
  },
92
68
  clearFailedCharge() {
93
69
  this.errorMessage = null;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lancom/shared",
3
- "version": "0.0.162",
3
+ "version": "0.0.164",
4
4
  "description": "lancom common scripts",
5
5
  "author": "e.tokovenko <e.tokovenko@gmail.com>",
6
6
  "repository": {
package/store/quote.js CHANGED
@@ -65,6 +65,9 @@ export const mutations = {
65
65
  setQuote(state, quote) {
66
66
  state.quote = quote;
67
67
  },
68
+ setOrder(state, order) {
69
+ state.quote.order = order;
70
+ },
68
71
  setOption(state, option) {
69
72
  state.option = option;
70
73
  },