NikolayBezay

SHW event to Adoric system for recommendations

Nov 4th, 2020
176
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
HTML 0.96 KB | None | 0 0
  1. <script>
  2.  (function () {
  3.         var pageProductFormTimer = 10;
  4.    
  5.         function sendProductId() {
  6.             var itemId = productForm = document.querySelector("#product_addtocart_form");
  7.             if (itemId) {
  8.                 itemId = itemId.getAttribute('data-product-sku');
  9.                 if (itemId.length > 0 && adoric) {
  10.                    adoric.trigger("pageview", {
  11.                      type: "product",
  12.                      ids: itemId,
  13.                    });
  14.                   }
  15.             }
  16.         }
  17.    
  18.         function waitPageProduct() {
  19.             pageProductFormTimer--;
  20.             var productForm = document.querySelector("#product_addtocart_form");
  21.             if (!productForm && pageProductFormTimer > 0) {
  22.                  setTimeout(waitPageProduct, 1000);
  23.             } else if (pageProductFormTimer > 0) {
  24.                   sendProductId();
  25.             }
  26.         }
  27.         waitPageProduct();
  28.     })();
  29. </script>
Advertisement
Add Comment
Please, Sign In to add comment