@lancom/shared 0.0.163 → 0.0.165
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/assets/js/utils/gtm.js
CHANGED
|
@@ -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
|
|
|
@@ -252,21 +252,7 @@ export default {
|
|
|
252
252
|
}
|
|
253
253
|
},
|
|
254
254
|
sendConversionData() {
|
|
255
|
-
|
|
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
|
/*
|
package/mixins/payment.js
CHANGED
|
@@ -63,31 +63,7 @@ export default {
|
|
|
63
63
|
}
|
|
64
64
|
},
|
|
65
65
|
sendConversionData() {
|
|
66
|
-
|
|
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;
|