templates/product.html.twig line 1

Open in your IDE?
  1. {% extends 'base.html.twig' %}
  2. {# Some helpers to make this file more readable #}
  3. {% set d = product.default_variation|default %}
  4. {% block main %}
  5.     <div class="max-w-screen-2xl mx-auto px-5 lg:px-20 pt-header">
  6.         {% include 'template-parts/breadcrumb.html.twig' %}
  7.     </div>
  8.     <main id="product-{{ product.id }}"
  9.           x-init="$nextTick(() => { initialize() })"
  10.             {% if d %}
  11.                 x-data="window.alpineProductData({{ product | json_encode }}, {{ product['default_variation'] | json_encode }})"
  12.             {% else %}
  13.                 x-data="window.alpineProductData({{ product | json_encode }})"
  14.             {% endif %}
  15.           class="max-w-screen-2xl mx-auto px-5 lg:px-20">
  16.         <div class="grid grid-cols-1 lg:grid-cols-2 lg:grid-rows-[0.02fr_1fr] gap-y-6 lg:gap-x-12 lg:gap-y-4 pb-0 lg:pb-12">
  17.             <div class="swiper-container-wrapper product-gallery -ml-4 lg:ml-0 w-screen lg:w-full flex flex-col sm:flex-row-reverse flex-nowrap gap-4 lg:aspect-[677/400] lg:overflow-hidden order-2 lg:order-first">
  18.                 {% if product.gallery|default or product.galleryVariations|default %}
  19.                     <div class="swiper group/product-page-swiper w-full lg:w-[calc(100%-100px)] relative !z-5">
  20.                         {% if product.discount|default %}
  21.                             {% embed 'components/picto.html.twig' with {picto_name: '- ' ~ product.discount ~ '%'} %}{% endembed %}
  22.                         {% endif %}
  23.                         {% if product.video|default %}
  24.                             <button data-modal-target="{{ product.video }}"
  25.                                     class="absolute top-4 right-4 z-100 flex w-max flex-row items-center gap-2 rounded-none bg-neutral-200 py-1 px-3">
  26.                                 {% include 'assets/youtube_icon.svg' %}
  27.                                 <span class="text-sm font-bold text-black">Ver vĂ­deo</span>
  28.                             </button>
  29.                         {% endif %}
  30.                         <div class="swiper-wrapper">
  31.                             <template x-for="item in current?.gallery || []">
  32.                                 <div class="swiper-slide">
  33.                                     <template x-if="item.src">
  34.                                         <a :href="item.src" :data-pswp-src="item.src" :data-pswp-width="1024"
  35.                                            :data-pswp-height="1024" class="cursor-zoom-in" rel="noreferrer">
  36.                                             <img class="w-full h-full aspect-[4/3] object-contain"
  37.                                                  :src="item.src"
  38.                                                  :srcset="item.srcset"
  39.                                                  :sizes="item.sizes"
  40.                                                  :alt="item.alt" loading="lazy">
  41.                                         </a>
  42.                                     </template>
  43.                                 </div>
  44.                             </template>
  45.                             {% for image in product.gallery %}
  46.                                 <div class="swiper-slide">
  47.                                     {% if image.src|default %}
  48.                                         <a href="{{ image.src }}" data-pswp-src="{{ image.src }}" data-pswp-width="1024"
  49.                                            data-pswp-height="1024" class="cursor-zoom-in" rel="noreferrer">
  50.                                             <img class="w-full h-full aspect-[4/3] object-contain"
  51.                                                  src="{{ image.src }}"
  52.                                                  srcset="{{ image.srcset }}"
  53.                                                  sizes="{{ image.sizes }}"
  54.                                                  alt="{{ image.alt }}" loading="lazy">
  55.                                         </a>
  56.                                     {% endif %}
  57.                                     {% if image.youtube_id|default %}
  58.                                         <iframe src="{{ image.youtube_src }}" class="w-full h-full"
  59.                                                 width="640" height="360" frameborder="0"
  60.                                                 allow="autoplay; fullscreen; picture-in-picture"
  61.                                                 allowfullscreen></iframe>
  62.                                     {% endif %}
  63.                                 </div>
  64.                             {% endfor %}
  65.                         </div>
  66.                         <div class="swiper-scrollbar lg:opacity-0 group-[.swiper-initialized:hover]/product-page-swiper:opacity-100 transition-opacity duration-300 ease-in-out"></div>
  67.                         <div class="swiper-button-next aria-disabled:hidden after:hidden" aria-disabled="true">
  68.                             {% include 'assets/swiper-next.svg' %}
  69.                         </div>
  70.                         <div class="swiper-button-prev aria-disabled:hidden after:hidden" aria-disabled="true">
  71.                             {% include 'assets/swiper-prev.svg' %}
  72.                         </div>
  73.                     </div>
  74.                     <div class="swiper product-page-swiper-thumbs w-[100px] !hidden lg:!block relative">
  75.                         <div class="swiper-wrapper">
  76.                             <template x-for="item in current?.gallery || []">
  77.                                 <div class="swiper-slide !h-auto cursor-pointer last:!mb-0">
  78.                                     <template x-if="item.src">
  79.                                         <img :src="item.thumbnail.src"
  80.                                              :alt="item.alt" loading="lazy">
  81.                                     </template>
  82.                                 </div>
  83.                             </template>
  84.                             {% for image in product.gallery %}
  85.                                 <div class="swiper-slide !h-auto cursor-pointer last:!mb-0">
  86.                                     <img src="{{ image.thumbnail.src }}"
  87.                                          alt="Miniatura {{ image.thumbnail.alt|default ? image.thumbnail.alt : image.alt }}"
  88.                                          loading="lazy">
  89.                                 </div>
  90.                             {% endfor %}
  91.                         </div>
  92.                         <div class="swiper-button-next swiper-button-next-thumbs !top-auto !bottom-0 !left-0 !right-0 !mt-0 m-auto aria-disabled:hidden after:hidden"
  93.                              aria-disabled="true">
  94.                             {% include 'assets/swiper-next-thumbs.svg' %}
  95.                         </div>
  96.                         <div class="swiper-button-prev swiper-button-prev-thumbs !top-0 !left-0 !right-0 !mt-0 m-auto aria-disabled:hidden after:hidden"
  97.                              aria-disabled="true">
  98.                             {% include 'assets/swiper-prev-thumbs.svg' %}
  99.                         </div>
  100.                     </div>
  101.                 {% endif %}
  102.             </div>
  103.             <div class="row-span-1">
  104.                 <h1 class="text-3xl lg:max-w-lg">{{ product.name }}</h1>
  105.             </div>
  106.             <div class="lg:row-span-2 order-4">
  107.                 <div class="lg:sticky lg:top-header flex flex-col gap-y-6 z-0 sm:max-xl max-w-lg">
  108.                     {% block start_sticky_product %}{% endblock %}
  109.                     {% block price_box %}
  110.                         {% embed 'template-parts/price-box.html.twig' %}{% endembed %}
  111.                     {% endblock %}
  112.                     {% block info_destacada %}
  113.                         {% embed 'components/info-destacada.html.twig' with {
  114.                             envio: true,
  115.                             tiempo_envio: product.attributes['pa_tiempo-de-envio'][0].name ?? '',
  116.                             size: product.length|default or product.width|default or product.height|default
  117.                         } only %}{% endembed %}
  118.                     {% endblock %}
  119.                     {% if product.short_description|default %}
  120.                         <span class="order-last lg:order-none text-sm text-black prose max-w-none">{{ product.short_description|raw }}</span>
  121.                     {% endif %}
  122.                     {% if product.is_in_stock|default %}
  123.                         {% if product.variation_attributes|default %}
  124.                             <div id="product-attributes"
  125.                                  class="space-y-6 bg-stone-100 xs:rounded-none p-4 w-screen -ml-4 xs:w-full xs:ml-0">
  126.                                 {% block product_attributes %}
  127.                                     {% for key, attribute in product.variation_attributes %}
  128.                                         {% embed 'components/attributes/attribute-button.html.twig' with {
  129.                                             atributos: 'product.variation_attributes["' ~ key ~ '"]',
  130.                                             atributo: key,
  131.                                         } only %}
  132.                                         {% endembed %}
  133.                                     {% endfor %}
  134.                                 {% endblock %}
  135.                             </div>
  136.                         {% endif %}
  137.                         {% block add_to_cart %}
  138.                             {% embed 'components/add-to-cart.html.twig' with {
  139.                                 quantity: true
  140.                             } %}{% endembed %}
  141.                         {% endblock %}
  142.                         {% block after_add_to_cart %}{% endblock %}
  143.                     {% else %}
  144.                         <div class="flex flex-row items-center gap-3 mt-6">
  145.                             <button id="addToCart"
  146.                                     class="no-stock w-full flex flex-row justify-center items-center gap-3 rounded-none bg-black p-3 text-white text-center">
  147.                                 <span>Producto agotado</span>
  148.                             </button>
  149.                         </div>
  150.                     {% endif %}
  151.                     <a href="{{ path('whatsapp_link', {'link': app.request.pathInfo}) }}" target="_blank"
  152.                        rel="nofollow" class="[&_svg]:max-w-40
  153.                         [&_svg]:max-h-40 [&_svg]:w-full [&_svg]:h-auto [&_svg]:object-contain">
  154.                         {% include 'assets/whatsapp-herramientasparaalicatador.svg' %}
  155.                     </a>
  156.                 </div>
  157.                 {% block price_nav_fixed %}
  158.                     {% embed 'template-parts/price-nav-fixed.html.twig' %}{% endembed %}
  159.                 {% endblock %}
  160.             </div>
  161.             <div class="order-last lg:order-3 mt-0 lg:mt-[400px] mb-8">
  162.                 {% block before_accordion %}{% endblock %}
  163.                 {% if product.accordion|default %}
  164.                     {% embed 'components/accordion.html.twig' with {
  165.                         id: 'accordion_product',
  166.                         accordion: 'collapse',
  167.                         items: product.accordion
  168.                     } %}
  169.                     {% endembed %}
  170.                 {% endif %}
  171.             </div>
  172.             {% if product.video|default %}
  173.                 {% embed 'components/modal.html.twig' with {id: product.video, modal_button_class: 'hidden', youtube_id: product.video, modal_zIndex: 'z-[1000001]'} %}{% endembed %}
  174.             {% endif %}
  175.             {% block modales_producto %}{% endblock %}
  176.         </div>
  177.         {% block informacion_adicional_producto %}{% endblock %}
  178.     </main>
  179.     {% block after_main %}{% endblock %}
  180.     {% if product.upsell_ids|default %}
  181.         <section class="max-w-screen-2xl mx-auto px-5 lg:px-20 flex flex-col gap-8">
  182.             {{ render_block('listadoproductos', {
  183.                 titulo: product.tituloProductosRelacionados ?? 'Productos relacionados' ,
  184.                 alineacion: 'start',
  185.                 categorias_productos: false,
  186.                 etiquetas_productos: false,
  187.                 numero_productos: '-1',
  188.                 boton: '',
  189.                 slider_grid: 'slider',
  190.                 productos: product.upsell_ids,
  191.                 id: 'relacionados',
  192.             }) }}
  193.         </section>
  194.     {% endif %}
  195. {% endblock %}
  196. {% block footer %}
  197.     {% include 'footer.html.twig' %}
  198.     <div class="pb-44 lg:pb-16"></div>
  199.     <style>
  200.         #whatsapp {
  201.             margin-bottom: 5rem;
  202.         }
  203.     </style>
  204.     {{ wp_footer() }}
  205. {% endblock footer %}
  206. {% block json_schema %}
  207.     {{ json_schema|raw }}
  208. {% endblock %}