Skip to content

Instantly share code, notes, and snippets.

@danielmcclure
Last active February 13, 2018 01:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save danielmcclure/2b0e4183cd76f50d6c7ac0d06f947d17 to your computer and use it in GitHub Desktop.
Save danielmcclure/2b0e4183cd76f50d6c7ac0d06f947d17 to your computer and use it in GitHub Desktop.
Build Commission Factory Product Purchase List from Data Layer
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