Skip to content

Commit be8cad6

Browse files
committed
updated datalayer object
1 parent e852271 commit be8cad6

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

src/shared/environment-data-sources/dutchie-plus.ts

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -89,11 +89,12 @@ const dutchiePlusDataSource = () => {
8989
// // set order id to local storage to prevent duplicate events
9090
// localStorage.setItem("orderNumber", orderNumber);
9191

92-
const items = data?.ecommerce?.purchase?.products;
92+
const items = data?.ecommerce?.purchase?.products || data?.ecommerce?.items;
9393

94-
const getId = data?.ecommerce?.purchase?.actionField?.id;
95-
const getRevenue = data?.ecommerce?.purchase?.actionField?.revenue;
96-
const getTax = data?.ecommerce?.purchase?.actionField?.tax;
94+
const getId = data?.ecommerce?.purchase?.actionField?.id || data?.ecommerce?.transaction_id;
95+
const getRevenue = data?.ecommerce?.purchase?.actionField?.revenue || data?.ecommerce?.value;
96+
const getTax = data?.ecommerce?.purchase?.actionField?.tax || data?.ecommerce?.tax;
97+
const additionalIds = data?.ecommerce?.product_ids || [];
9798

9899
if (getId) {
99100
observable.notify({
@@ -106,12 +107,13 @@ const dutchiePlusDataSource = () => {
106107
state: "N/A",
107108
country: "USA",
108109
currency: "USD",
110+
alternativeTransactionIds: additionalIds,
109111
items: items.map((item) => {
110112
return {
111113
orderId: getId,
112-
sku: item.id,
113-
name: item.name,
114-
category: item.category,
114+
sku: item.id || item.item_id,
115+
name: item.name || item.item_name,
116+
category: item.category || item.item_category,
115117
unitPrice: parseFloat(item.price),
116118
quantity: parseInt(item.quantity),
117119
currency: "USD",

0 commit comments

Comments
 (0)