Last active
June 21, 2021 17:26
-
-
Save adardesign/0f80d53e6b9089aa8790c00e9e6a6644 to your computer and use it in GitHub Desktop.
TEST
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// WPR20-101 | |
adrma.init.add({ | |
name: "annexCloudPixel", | |
cb: function() { | |
//if (adrma.siteSettings.enableAnnexCloud === false) return; // no need to create a siteSetting, this is just a hook in case we want to kill this. | |
adrma.receipt.gotSummary.then(function gotReceiptSummary(response) { | |
if (!adrma.receipt.isLoadedFirstTime(response.data.orderId, "annexCloud")) return; | |
var coupons = response.data.summary.coupons; | |
// TODO: since this is a array, get the coupon codes string, and the first only | |
if (coupons.length === 0) { | |
coupons = ""; | |
} else { | |
coupons = coupons.toString(); | |
} | |
var items = []; | |
for (var i = 0; i < response.data.purchasedItems.length; i++) { | |
items.push({ | |
"id": response.data.purchasedItems[i].sku, //Pass the Product ID, which you have passed earlier to the Annex Cloud’s API or code | |
"price": response.data.purchasedItems[i].price, | |
"qty": response.data.purchasedItems[i].quantity, | |
"product_name": response.data.purchasedItems[i].title, | |
"product_url": response.data.purchasedItems[i].url, | |
"product_image_url": "https:" + response.data.purchasedItems[i].imageUrl, | |
"category_id": "", | |
"category_name": response.data.purchasedItems[i].category | |
}); | |
var arrExcludeProduct = JSON.stringify(items); | |
} | |
adrma.fetchData({ | |
url: "https://c.socialannex.com/c-sale-track/?site_id=" + adrma.siteSettings.annexCloudID + "&order_id=" + response.data.orderId + "&sale_amount=" + response.data.summary.subTotal + "&email_id=" + response.data.email + "&coupon=" + coupons + "&exclude_products=" + arrExcludeProduct, | |
dataType: "script" | |
}); | |
}); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment