Last active
February 13, 2018 01:20
-
-
Save danielmcclure/2b0e4183cd76f50d6c7ac0d06f947d17 to your computer and use it in GitHub Desktop.
Build Commission Factory Product Purchase List from Data Layer
This file contains 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
function() { | |
var productList = {{DLV - eCommerce - transactionProducts}}; // Data Layer - Ecommerce Product Array | |
var products=''; | |
// Builds the product adder for each item in array | |
for (var i = 0; i < productList.length; i++) { | |
var products = products+'cf("add", "items", { "sku": "'+(productList[i].sku)+'", "price": "'+(productList[i].price)+'", "quantity": "'+(productList[i].quantity)+'" }); \n'; | |
} | |
// Outputs products formatted for CF | |
return products; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment