1// this part of the code is deprecated and will be removed in a later version 2// therefore jQuery usage will be not rewritten 3// turn of the deprecated standard/classic ecommerce feature and this code will not execute 4jQuery(function() { 5 jQuery( document ).on( 'click', '.add_to_cart_button:not(.product_type_variable, .product_type_grouped, .single_add_to_cart_button)', function() { 6 var productdata = jQuery( this ).closest( '.product' ).find( '.gtm4wp_productdata' ); 7 8 window[ gtm4wp_datalayer_name ].push({ 9 'event': 'gtm4wp.addProductToCart', 10 'productName': productdata.data( 'gtm4wp_product_name' ), 11 'productSKU': jQuery( this ).data( 'product_sku' ), 12 'productID': jQuery( this ).data( 'product_id' ), 13 }); 14 }); 15 16 jQuery( document ).on( 'click', '.single_add_to_cart_button', function() { 17 var _product_form = jQuery( this ).closest( 'form.cart' ); 18 var _product_id = jQuery( '[name=gtm4wp_id]', _product_form ).val(); 19 var _product_name = jQuery( '[name=gtm4wp_name]', _product_form ).val(); 20 var _product_sku = jQuery( '[name=gtm4wp_sku]', _product_form ).val();
21 var _product_is_grouped = jQuery( _product_form ).hasClass( 'grouped_form' ); 22 23 if ( ! _product_is_grouped ) { 24 window[ gtm4wp_datalayer_name ].push({ 25 'event': 'gtm4wp.addProductToCart', 26 'productName': _product_name, 27 'productSKU': _product_sku, 28 'productID': _product_id 29 }); 30 } 31 }); 32});
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.