Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /** SHOPIFY CHECKOUT PAGE - GTM JS VARIABLES */
- //Return the Product_IDs as an array
- function() {
- var prods = window.Shopify.checkout.line_items;
- var prod_ids = [];
- var i;
- if (!prods) {
- return;
- }
- for (i = 0; i < prods.length; i++) {
- if (prods[i].product_id) {
- prod_ids.push(prods[i].product_id);
- }
- }
- return prod_ids;
- }
- //Return the Product_IDs as a comma separated list (string)
- function() {
- var prods = window.Shopify.checkout.line_items;
- var prod_ids = [];
- var i;
- if (!prods) {
- return;
- }
- for (i = 0; i < prods.length; i++) {
- if (prods[i].product_id) {
- prod_ids.push(prods[i].product_id);
- }
- }
- return prod_ids.join(' , ');
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement