@sentecacommerce-theme/lib 0.14.8 → 0.14.9

Sign up to get free protection for your applications and to get access to all the features.
@@ -15,7 +15,7 @@ var purchase = function(order, config) {
15
15
  var isGtagLoaded = Boolean(window.gtag);
16
16
  var hasGoogleId = Boolean((ref8 = config.google) === null || ref8 === void 0 ? void 0 : ref8.analytics);
17
17
  if (isGtagLoaded && hasGoogleId) {
18
- var ref9, ref10, ref11;
18
+ var ref9, ref10, ref11, ref12;
19
19
  var items = ((ref9 = order.lineItems) === null || ref9 === void 0 ? void 0 : ref9.map(function(item, i) {
20
20
  return {
21
21
  id: item.variant.sku,
@@ -23,36 +23,36 @@ var purchase = function(order, config) {
23
23
  list_name: config.defaultMerchant,
24
24
  list_position: i + 1,
25
25
  quantity: item.quantity,
26
- price: (0, _decodePrice).decodePrice(item.totalPrice)
26
+ price: (item === null || item === void 0 ? void 0 : item.totalPrice) && (0, _decodePrice).decodePrice(item.totalPrice)
27
27
  };
28
28
  })) || [];
29
- (ref11 = window.gtag) === null || ref11 === void 0 ? void 0 : ref11.call(window, 'event', 'purchase', {
29
+ (ref12 = window.gtag) === null || ref12 === void 0 ? void 0 : ref12.call(window, 'event', 'purchase', {
30
30
  transaction_id: order._id,
31
31
  send_to: (ref10 = config.google) === null || ref10 === void 0 ? void 0 : ref10.analytics,
32
32
  affiliation: config.defaultMerchant,
33
33
  value: (0, _decodePrice).decodePrice(order.grandTotalPrice),
34
34
  currency: order.currencyCode,
35
35
  tax: (0, _decodePrice).decodePrice(centAmount),
36
- shipping: (order === null || order === void 0 ? void 0 : order.shippings) ? (0, _decodePrice).decodePrice(order.shippings[0].price) : 0,
36
+ shipping: (order === null || order === void 0 ? void 0 : order.shippings) ? (0, _decodePrice).decodePrice((ref11 = order.shippings[0]) === null || ref11 === void 0 ? void 0 : ref11.price) : 0,
37
37
  items: items
38
38
  });
39
39
  }
40
40
  if (isGtagLoaded && hasGoogleReMarketing) {
41
- var ref12, ref13, ref14, ref15, ref16;
42
- (ref16 = window.gtag) === null || ref16 === void 0 ? void 0 : ref16.call(window, 'event', 'conversion', {
43
- send_to: "".concat((ref12 = config.google) === null || ref12 === void 0 ? void 0 : (ref13 = ref12.reMarketing) === null || ref13 === void 0 ? void 0 : ref13.id, "/").concat((ref14 = config.google) === null || ref14 === void 0 ? void 0 : (ref15 = ref14.reMarketing) === null || ref15 === void 0 ? void 0 : ref15.label),
41
+ var ref13, ref14, ref15, ref16, ref17;
42
+ (ref17 = window.gtag) === null || ref17 === void 0 ? void 0 : ref17.call(window, 'event', 'conversion', {
43
+ send_to: "".concat((ref13 = config.google) === null || ref13 === void 0 ? void 0 : (ref14 = ref13.reMarketing) === null || ref14 === void 0 ? void 0 : ref14.id, "/").concat((ref15 = config.google) === null || ref15 === void 0 ? void 0 : (ref16 = ref15.reMarketing) === null || ref16 === void 0 ? void 0 : ref16.label),
44
44
  value: (0, _decodePrice).decodePrice(order.grandTotalPrice),
45
45
  currency: order.currencyCode,
46
46
  transaction_id: order._id
47
47
  });
48
48
  }
49
49
  if (facebookPixelLoaded) {
50
- var ref17, ref18;
51
- (ref18 = window.fbq) === null || ref18 === void 0 ? void 0 : ref18.call(window, 'track', 'Purchase', {
50
+ var ref18, ref19;
51
+ (ref19 = window.fbq) === null || ref19 === void 0 ? void 0 : ref19.call(window, 'track', 'Purchase', {
52
52
  currency: order.currencyCode,
53
53
  value: (0, _decodePrice).decodePrice(order.grandTotalPrice),
54
54
  content_type: 'product',
55
- contents: ((ref17 = order.lineItems) === null || ref17 === void 0 ? void 0 : ref17.map(function(product) {
55
+ contents: ((ref18 = order.lineItems) === null || ref18 === void 0 ? void 0 : ref18.map(function(product) {
56
56
  return {
57
57
  id: product.variant.sku,
58
58
  quantity: product.quantity
@@ -11,7 +11,7 @@ export var purchase = function(order, config) {
11
11
  var isGtagLoaded = Boolean(window.gtag);
12
12
  var hasGoogleId = Boolean((ref8 = config.google) === null || ref8 === void 0 ? void 0 : ref8.analytics);
13
13
  if (isGtagLoaded && hasGoogleId) {
14
- var ref9, ref10, ref11;
14
+ var ref9, ref10, ref11, ref12;
15
15
  var items = ((ref9 = order.lineItems) === null || ref9 === void 0 ? void 0 : ref9.map(function(item, i) {
16
16
  return {
17
17
  id: item.variant.sku,
@@ -19,36 +19,36 @@ export var purchase = function(order, config) {
19
19
  list_name: config.defaultMerchant,
20
20
  list_position: i + 1,
21
21
  quantity: item.quantity,
22
- price: decodePrice(item.totalPrice)
22
+ price: (item === null || item === void 0 ? void 0 : item.totalPrice) && decodePrice(item.totalPrice)
23
23
  };
24
24
  })) || [];
25
- (ref11 = window.gtag) === null || ref11 === void 0 ? void 0 : ref11.call(window, 'event', 'purchase', {
25
+ (ref12 = window.gtag) === null || ref12 === void 0 ? void 0 : ref12.call(window, 'event', 'purchase', {
26
26
  transaction_id: order._id,
27
27
  send_to: (ref10 = config.google) === null || ref10 === void 0 ? void 0 : ref10.analytics,
28
28
  affiliation: config.defaultMerchant,
29
29
  value: decodePrice(order.grandTotalPrice),
30
30
  currency: order.currencyCode,
31
31
  tax: decodePrice(centAmount),
32
- shipping: (order === null || order === void 0 ? void 0 : order.shippings) ? decodePrice(order.shippings[0].price) : 0,
32
+ shipping: (order === null || order === void 0 ? void 0 : order.shippings) ? decodePrice((ref11 = order.shippings[0]) === null || ref11 === void 0 ? void 0 : ref11.price) : 0,
33
33
  items: items
34
34
  });
35
35
  }
36
36
  if (isGtagLoaded && hasGoogleReMarketing) {
37
- var ref12, ref13, ref14, ref15, ref16;
38
- (ref16 = window.gtag) === null || ref16 === void 0 ? void 0 : ref16.call(window, 'event', 'conversion', {
39
- send_to: "".concat((ref12 = config.google) === null || ref12 === void 0 ? void 0 : (ref13 = ref12.reMarketing) === null || ref13 === void 0 ? void 0 : ref13.id, "/").concat((ref14 = config.google) === null || ref14 === void 0 ? void 0 : (ref15 = ref14.reMarketing) === null || ref15 === void 0 ? void 0 : ref15.label),
37
+ var ref13, ref14, ref15, ref16, ref17;
38
+ (ref17 = window.gtag) === null || ref17 === void 0 ? void 0 : ref17.call(window, 'event', 'conversion', {
39
+ send_to: "".concat((ref13 = config.google) === null || ref13 === void 0 ? void 0 : (ref14 = ref13.reMarketing) === null || ref14 === void 0 ? void 0 : ref14.id, "/").concat((ref15 = config.google) === null || ref15 === void 0 ? void 0 : (ref16 = ref15.reMarketing) === null || ref16 === void 0 ? void 0 : ref16.label),
40
40
  value: decodePrice(order.grandTotalPrice),
41
41
  currency: order.currencyCode,
42
42
  transaction_id: order._id
43
43
  });
44
44
  }
45
45
  if (facebookPixelLoaded) {
46
- var ref17, ref18;
47
- (ref18 = window.fbq) === null || ref18 === void 0 ? void 0 : ref18.call(window, 'track', 'Purchase', {
46
+ var ref18, ref19;
47
+ (ref19 = window.fbq) === null || ref19 === void 0 ? void 0 : ref19.call(window, 'track', 'Purchase', {
48
48
  currency: order.currencyCode,
49
49
  value: decodePrice(order.grandTotalPrice),
50
50
  content_type: 'product',
51
- contents: ((ref17 = order.lineItems) === null || ref17 === void 0 ? void 0 : ref17.map(function(product) {
51
+ contents: ((ref18 = order.lineItems) === null || ref18 === void 0 ? void 0 : ref18.map(function(product) {
52
52
  return {
53
53
  id: product.variant.sku,
54
54
  quantity: product.quantity
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@sentecacommerce-theme/lib",
3
3
  "sideEffects": false,
4
- "version": "0.14.8",
4
+ "version": "0.14.9",
5
5
  "main": "dist/cjs/index.js",
6
6
  "module": "dist/esm/index.js",
7
7
  "types": "dist/types/index.d.ts",
@@ -31,13 +31,13 @@
31
31
  "watch:cjs": "swc src --out-dir dist/cjs -w",
32
32
  "watch:esm": "swc src --out-dir dist/esm --no-swcrc -w"
33
33
  },
34
- "gitHead": "556a26ab90b2169a12b698de7a8117efa6069664",
34
+ "gitHead": "704001f1791d48eef43ecd862836cc22da13a067",
35
35
  "peerDependencies": {
36
36
  "react-query": "^2.26.2"
37
37
  },
38
38
  "dependencies": {
39
- "@sentecacommerce-theme/base": "^0.14.8",
40
- "@sentecacommerce-theme/cms": "^0.14.8",
39
+ "@sentecacommerce-theme/base": "^0.14.9",
40
+ "@sentecacommerce-theme/cms": "^0.14.9",
41
41
  "@sentecacommerce/sdk": "2.0.175",
42
42
  "body-scroll-lock": "^3.1.5",
43
43
  "copy-to-clipboard": "^3.3.1",