custom/plugins/VirginTheme/src/Resources/views/storefront/page/content/index.html.twig line 1

Open in your IDE?
  1. {% sw_extends '@Storefront/storefront/page/content/index.html.twig' %}
  2. {% block page_content %}
  3. {% include '@LeadManager/storefront/page/loading/loading.html.twig' %}
  4. {# INFO: Delete breadcrumb #}
  5. <div class="cms-page">
  6. {% block page_content_blocks %}
  7. {% sw_include "@Storefront/storefront/page/content/detail.html.twig" with {'cmsPage': page.cmsPage} %}
  8. {% endblock %}
  9. </div>
  10. {% endblock %}
  11. {% block base_body %}
  12. {{ parent() }}
  13. <script type="text/javascript">
  14. let envChannel = "d";
  15. if ( window.innerWidth <= 1024 && window.innerWidth >= 768 ) {
  16. envChannel = "t";
  17. } else if ( window.innerWidth <= 768 ){
  18. envChannel = "m";
  19. }
  20. let listProducts = [];
  21. let productBoxes = document.querySelectorAll('.cms-element-virgin-product-box');
  22. let listProductCurrentPriceTf = '';
  23. for (let i = 0; i < productBoxes.length; ++i) {
  24. if (productBoxes[i].querySelector('.product-price')) {
  25. listProductCurrentPriceTf = productBoxes[i].querySelector('.product-price');
  26. } else if (productBoxes[i].querySelector('.total-price-discount')) {
  27. listProductCurrentPriceTf = productBoxes[i].querySelector('.total-price-discount');
  28. } else {
  29. let totalPriceBase = productBoxes[i].querySelectorAll('.total-price-base');
  30. if (totalPriceBase.length > 1) {
  31. listProductCurrentPriceTf = totalPriceBase[1];
  32. } else {
  33. listProductCurrentPriceTf = totalPriceBase[0];
  34. }
  35. }
  36. listProducts.push({
  37. list_product_id: productBoxes[i].querySelector('input[name="product-id"]').value,
  38. list_product_name: productBoxes[i].querySelector('input[name="product-name"]').value,
  39. list_product_currentprice_tf: listProductCurrentPriceTf.innerText.match(/[+-]?\d+(\.\d+)?/)[0],
  40. list_product_url_page: '',
  41. list_product_url_picture: '',
  42. });
  43. }
  44. var tc_vars = {
  45. env_template : "listing",
  46. env_channel : envChannel,
  47. env_work : "{{ app.request.server.get('APP_ENV') }}",
  48. env_language : "{{ tagCommanderVariables['envLanguage'] }}",
  49. env_country : "{{ tagCommanderVariables['envCountry'] }}",
  50. env_currency : "{{ tagCommanderVariables['envCurrency'] }}",
  51. user_id : "{{ tagCommanderVariables['userId'] }}",
  52. user_email : "{{ tagCommanderVariables['userEmail'] }}",
  53. category_id : "{{ tagCommanderVariables['categoryId'] }}",
  54. category_name : "{{ tagCommanderVariables['categoryName'] }}",
  55. list_products : listProducts
  56. }
  57. function tagCommanderEventDatalayerTrigger(product) {
  58. if ("undefined" === typeof tC) {
  59. return;
  60. }
  61. let productVirginExerpType = product.customFields['virgin_exerp_type'];
  62. if (productVirginExerpType === 'EFT') {
  63. tC.event.acqMens(
  64. this,
  65. {
  66. 'id': 'AcqMens',
  67. 'user_email': "{{ tagCommanderVariables['userEmail'] }}",
  68. 'product_id': product.productNumber,
  69. 'product_sku': product.name,
  70. 'product_name': product.name,
  71. 'product_originalprice_ati': product.price[0].gross,
  72. 'product_discount_ati': '',
  73. 'product_currentprice_tf': '',
  74. 'product_url_page': '',
  75. 'product_url_picture': ''
  76. }
  77. );
  78. } else if (productVirginExerpType === 'CASH') {
  79. tC.event.acqAnn(
  80. this,
  81. {
  82. 'id': 'AcqAnn',
  83. 'user_email': "{{ tagCommanderVariables['userEmail'] }}",
  84. 'product_id': product.productNumber,
  85. 'product_sku': product.name,
  86. 'product_name': product.name,
  87. 'product_originalprice_ati': product.price[0].gross,
  88. 'product_discount_ati': '',
  89. 'product_currentprice_tf': '',
  90. 'product_url_page': '',
  91. 'product_url_picture': ''
  92. }
  93. );
  94. } else {
  95. tC.event.acqGen(
  96. this,
  97. {
  98. 'id': 'AcqGen',
  99. 'user_email': "{{ tagCommanderVariables['userEmail'] }}",
  100. 'product_id': product.productNumber,
  101. 'product_sku': product.name,
  102. 'product_name': product.name,
  103. 'product_originalprice_ati': product.price[0].gross,
  104. 'product_discount_ati': '',
  105. 'product_currentprice_tf': '',
  106. 'product_url_page': '',
  107. 'product_url_picture': ''
  108. }
  109. );
  110. }
  111. }
  112. </script>
  113. {% endblock %}