PluginProbe
Visual Website Optimizer / 4.7
Visual Website Optimizer v4.7
trunk 1.0 2.0 2.1 2.2 2.3 2.4 2.5 2.6 2.7 2.8 2.9 3.0 3.1 3.2 3.3 3.4 3.5 3.6 3.7 3.8 3.9 4.0 4.1 4.10 All 37 releases
visual-web-optimizer / templates / add.php

add.php in Visual Website Optimizer 4.7, at templates/add.php

45 lines 1.7 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php defined('ABSPATH') or exit; ?>
2 $('.single_add_to_cart_button').on('click', function() {
3 window.VWO = window.VWO || [];
4 VWO.event = VWO.event || function() {
5 VWO.push(["event"].concat([].slice.call(arguments)));
6 };
7 var productSku = '<?php echo $productSku ?>';
8 var productTitle = '<?php echo $productTitle ?>';
9 var price = <?php echo $price ?> ;
10 var productId = '<?php echo $productId ?>';
11 var productCategory = '<?php echo json_encode($productCategory) ?>';
12 var productUrl = '<?php echo $productUrl?>';
13
14 if ($('input[name="variation_id"]').val()) {
15 var variant = $('input[name="variation_id"]').val();
16
17 $.each($('.variations_form').data('product_variations'), function(index, product) {
18 if (product.variation_id == variant) {
19 if (product.hasOwnProperty('sku')) {
20 productSku = product.sku;
21 }
22 if (product.hasOwnProperty('display_price')) {
23 price = product.display_price;
24 }
25 if (product.hasOwnProperty('attributes')) {
26 productTitle += ' - ';
27 var attributes = Object.values(product.attributes).join(', ');
28 productTitle += attributes;
29 }
30 }
31 });
32 }
33
34 VWO.event("woocommerce.productAddedToCart", {
35 "productTitle": productTitle,
36 "productId": productId,
37 "quantity": $('input.qty').val() ? parseInt($('input.qty').val()) : 1,
38 "price": price,
39 "productCategory": productCategory,
40 "productUrl": productUrl,
41 "variantId": productSku,
42 "productSku": productSku
43 });
44 });
45