themes/BootstrapChildTheme/SyliusShopBundle/views/Product/show.html.twig line 77

Open in your IDE?
  1. {% extends '@SyliusShop/layout.html.twig' %}
  2. {% block stylesheets %}
  3.     {{ parent() }}
  4.     {{ encore_entry_link_tags('shop-product-detail', null, 'bootstrapTheme') }}
  5. {% endblock %}
  6. {% block javascripts %}
  7.     {{ parent() }}
  8.     {{ encore_entry_script_tags('shop-product-detail', null, 'bootstrapTheme') }}
  9.     {% include '@SyliusShop/_tracking/data_layer.html.twig' %}
  10.     <script>
  11.         (function () {
  12.             {# 1. Príprava dát v Twigu #}
  13.             {% set variant = product.variants.first %}
  14.             {% set tier_prices = variant.getTierPricesForChannel(sylius.channel, sylius.customer) %}
  15.             {% if tier_prices|length > 0 %}
  16.             {% set tier_price = tier_prices|first %}
  17.             {# JEDNOTKOVÁ CENA (napr. 0.03696) #}
  18.             {% set unit_price = tier_price.price / 100000 %}
  19.             {# MNOŽSTVO (napr. 16361) #}
  20.             {% set qty = tier_price.qty %}
  21.             {% else %}
  22.             {% set unit_price = variant|sylius_calculate_price_with_tax({'channel': sylius.channel, 'zone': sylius.channel.defaultTaxZone}) / 100000 %}
  23.             {% set qty = 1 %}
  24.             {% endif %}
  25.             {# 2. Celková hodnota pre GA4 (604.70) #}
  26.             const totalValue = {{ (unit_price * qty)|number_format(2, '.', '') }};
  27.             const unitPrice = {{ unit_price|number_format(5, '.', '') }};
  28.             const quantity = {{ qty }};
  29.             const item = {
  30.                 item_id: {{ product.code|json_encode|raw }},
  31.                 item_name: {{ product.name|json_encode|raw }},
  32.                 item_variant: {{ variant.code|json_encode|raw }},
  33.                 item_category: {{ product.mainTaxon ? product.mainTaxon.name|json_encode|raw : '"Unknown"' }},
  34.                 price: unitPrice,   // TU JE JEDNOTKOVÁ (0.03696)
  35.                 quantity: quantity  // TU JE QUANTITY (16361)
  36.             };
  37.             {# 3. Odoslanie do DataLayer #}
  38.             window.dataLayer = window.dataLayer || [];
  39.             window.dataLayer.push({ ecommerce: null });
  40.             window.dataLayer.push({
  41.                 event: "view_item",
  42.                 ecommerce: {
  43.                     currency: {{ sylius.currencyCode|json_encode|raw }},
  44.                     value: totalValue, // TU JE CELKOVÁ (604.70)
  45.                     items: [item]
  46.                 }
  47.             });
  48.             console.log("GA4 Detailný Debug:", {
  49.                 currency: {{ sylius.currencyCode|json_encode|raw }},
  50.                 value: totalValue, // TU JE CELKOVÁ (604.70)
  51.                 items: [item]
  52.             });
  53.         })();
  54.     </script>
  55. {% endblock %}
  56. {% block title %}
  57.     {{ sylius_template_event('dedi_sylius_seo_plugin.title', { resource: product ?? sylius.channel }) }}
  58. {% endblock %}
  59. {% block breadcrumb %}
  60.     {% include '@SyliusShop/Product/Show/_breadcrumb.html.twig' %}
  61. {% endblock %}
  62. {% block content %}
  63.     <div class="row product-detail">
  64.         <div class="col-md-3 d-none d-lg-block">
  65.             {% include '@SyliusShop/Product/Index/_sidebar.html.twig' %}
  66.         </div>
  67.         <div class="col-lg-9">
  68.             {% include '@SyliusShop/Product/Show/_header.html.twig' %}
  69.             <div class="row">
  70.                 <div class="col-sm-12 mb-4 col-md-6">
  71.                     {{ sylius_template_event('sylius.shop.product.show.left_sidebar', _context) }}
  72.                 </div>
  73.                 <div class="col-sm-12 col-md-6 ps-md-5">
  74.                     {{ sylius_template_event('sylius.shop.product.show.right_sidebar', _context) }}
  75.                 </div>
  76.             </div>
  77.             {{ sylius_template_event('sylius.shop.product.show.content', _context) }}
  78.         </div>
  79.     </div>
  80. {% endblock %}