1'use strict'; 2(function ($) { 3 if (typeof gtmEnhancedEcommerceUAEnabled !== 'undefined' && gtmEnhancedEcommerceUAEnabled) { 4 (function () { 5 if (typeof checkoutStepsConfiguration === "undefined") return; 6 if (typeof checkoutStepsConfiguration !== "object") return; 7 if (!checkoutStepsConfiguration.hasOwnProperty('enabled')) return; 8 if (checkoutStepsConfiguration.enabled === false) return; 9 if (!checkoutStepsConfiguration.hasOwnProperty('steps')) return; 10 11 for (var stepId in checkoutStepsConfiguration.steps) { 12 if (!checkoutStepsConfiguration.steps.hasOwnProperty(stepId)) continue; 13 14 checkoutStepsConfiguration.steps[stepId].forEach(function BindStep(conf) { 15 conf.stepId = stepId; 16 $(conf.selector).on(conf.event, function () { 17 var option = null; 18 19 if ( 20 typeof conf.option !== "undefined" 21 && typeof window[conf.option] === 'function' 22 ) { 23 option = window[conf.option].call(this); 24 } 25 26 enhancedEcommerceTrackCheckoutOption(conf.stepId, option); 27 }); 28 }); 29 } 30 })(); 31 } 32})(jQuery); 33 34/** 35 * This function will be called above if the configuration of 36 * %sylius_gtm_enhanced_ecommerce.features.checkout.steps.*.*.option% 37 * contains a function accessible into the window var. 38 * 39 * The 'this' context is the context of 40 * %sylius_gtm_enhanced_ecommerce.features.checkout.steps.*.*.selector% 41 * So if 'this' represent the current checkout form you can use it 42 * to restrict what you want to be stored into GA 43 * 44 * @returns {string} 45 */ 46function enhancedEcommerceCheckoutGetChoiceValue() { 47 return $('input[type=radio]:checked', this).val(); 48} 49 50/** 51 * @param {integer} stepId 52 * @param {string} checkoutOption 53 */ 54function enhancedEcommerceTrackCheckoutOption(stepId, checkoutOption) { 55 var obj = { 56 'event': 'checkoutOption', 57 'ecommerce': { 58 'checkout_option': { 59 'actionField': { 60 'step': stepId, 61 'option': checkoutOption 62 } 63 } 64 } 65 }; 66 67 /** global: dataLayer */ 68 dataLayer.push(obj); 69}
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.