templates/AtechNetCoreBundle/Checkout/cart.html.twig line 1

Open in your IDE?
  1. {% extends 'AtechNetCoreBundle/base.html.twig' %}
  2. {% import "AtechNetCoreBundle/macros.html.twig" as macros %}
  3. {% block content %}
  4.     {% set defaultLocale = app.request.session.get('defaultLocale') %}
  5.     <style>
  6.         .btn-back {
  7.             border-radius: 6px;
  8.             margin-right: 5px;
  9.             padding-left: 5px;
  10.         }
  11.     </style>
  12.     <div class="main-content checkout">
  13.         <div class="container">
  14.             {{ macros.printChceckoutSteps(stepsOptions) }}
  15.             {% if items is defined and items | length > 0 %}
  16.                 <div class="cart-content">
  17.                     <div class="cart-content-top">
  18.                         <div class="cart-content-line">
  19.                             <div class="heading-wrapper">
  20.                                 <div class="cart-heading">
  21.                                     <h1>{{ 'Shopping cart' | trans }}</h1>
  22.                                 </div>
  23.                             </div>
  24.                         </div>
  25.                         {% if not stock %}
  26.                             <div class="alert alert-danger mt-3" role="alert">
  27.                                 {{ 'Products marked with *** are not available in the desired quantity or not in stock' | trans }}
  28.                             </div>
  29.                         {% endif %}
  30.                         {% for message in app.flashes('success') %}
  31.                             <div class="alert alert-success" role="alert">
  32.                                 <i class="fa fa-check"></i>
  33.                                 <span>{{ message }}</span>
  34.                             </div>
  35.                         {% endfor %}
  36.                         {% set cartIncludesOnlyMainProductTypeItem = false %}
  37.                         {% for item in items %}
  38.                             {%- set cartIncludesOnlyMainProductTypeItem = item.typeId in [
  39.                                     const('ProductType::PRODUCT_TYPE_ID_MONITOR'),
  40.                                     const('ProductType::PRODUCT_TYPE_ID_NOTEBOOK'),
  41.                                     const('ProductType::PRODUCT_TYPE_ID_PC'),
  42.                                     const('ProductType::PRODUCT_TYPE_ID_PC_SET'),
  43.                                     const('ProductType::PRODUCT_TYPE_ID_ALL_IN_ONE'),
  44.                                     const('ProductType::PRODUCT_TYPE_ID_TABLET'),
  45.                                     const('ProductType::PRODUCT_TYPE_ID_SMARTPHONE')
  46.                                 ]
  47.                             -%}
  48.                             <div class="cart-content-line" data-id="{{ item.id }}">
  49.                                 <div class="row" style="margin-bottom: 4px;">
  50.                                     <div class="image-wrapper">
  51.                                         {% if item.image %}
  52.                                             <img loading="lazy" decoding="async" src="{{ item.image }}" alt="{{ item.name }}" width="57" height="43" />
  53.                                         {% endif %}
  54.                                     </div>
  55.                                     <div class="col-6 col-sm-6 col-lg-5 info-wrapper">
  56.                                         <a href="{{ item.href }}" class="cart-content-product-name main">{{- item.name -}}{%- if not item.stock -%}<span class="text-danger">***</span>{%- endif -%}</a>
  57.                                         <p class="cart-content-product-desc">
  58.                                             {{ item.description|replace({
  59.                                                 'Gold': ('grades.A')|trans,
  60.                                                 'Silver': ('grades.B')|trans,
  61.                                                 'Bronze': ('grades.C')|trans,
  62.                                             })  }}
  63.                                         </p>
  64.                                         {% if item.stock %}
  65.                                             <p class="cart-content-in-stock-text">{{ 'Cart item in stock text'|trans }}</p>
  66.                                         {% endif %}
  67.                                         <button class="remove remove-product" data-item="{{ item.id }}" data-loading-text="<i class='fas fa-spinner fa-spin' style='font-size: 18px; margin-left: 5px;'></i>" data-original-text="{{ 'Cart option remove text'|trans }}" data-option="0" data-product-id="{{ item.productId }}" data-name="{{ item.name }}">{{ 'Cart option remove text'|trans }}</button>
  68.                                     </div>
  69.                                     <div class="col-6 col-lg-4 quantity-wrapper">
  70.                                         {% if item.productId != const('Product::SUMMER_2026_COUPON_GIFT_ITEM_ID') and item.productId != const('Product::PEXESO_SCHOOL_GIFT_ITEM_ID') %}
  71.                                             {%- set stockItemCodes = app.session.get('stockItemCodes') -%}
  72.                                             {%- if stockItemCodes[item.productId] is not defined -%}
  73.                                                 <div class="qty-and-remove">
  74.                                                     <div class="product-quantity{% if domainId == 7 %} wide-product-quantity{% endif %}">
  75.                                                         <input type="text" value="{{ item.quantity }}" data-id="{{ item.id }}" autocomplete="off" aria-label="{{ "Product quantity"|trans }}">
  76.                                                         <button class="plus" type="button" data-id="{{ item.id }}" data-loading-text='<i class="far fa-cog fa-spin"></i>' aria-label="{{ "Increase product quantity"|trans }}"><i class="far fa-plus"></i></button>
  77.                                                         <button class="minus" type="button" data-id="{{ item.id }}" data-loading-text='<i class="far fa-cog fa-spin"></i>' aria-label="{{ "Decrease product quantity"|trans }}"><i class="far fa-minus"></i></button>
  78.                                                     </div>
  79.                                                 </div>
  80.                                             {%- endif -%}
  81.                                             {%- if stockItemCodes and stockItemCodes[item.productId] is defined -%}
  82.                                                 <div class="serial-numbers w-100 d-flex flex-row flex-wrap">
  83.                                                     <p class="mb-1 col-12">{{ 'Serial numbers'|trans }}:</p>
  84.                                                     {%- for stockItemId in stockItemCodes[item.productId] -%}
  85.                                                         <label class="alert-info px-2 py-1 me-1 mb-1 d-flex flex-row justify-content-between align-items-center" style="width: max-content;"><small>#{{ stockItemId }}</small><i class="far fa-times ms-1 d-flex flex-row justify-content-between align-items-center" style="color: #e45050; cursor: pointer;" onClick="stockItemRemove({{ item.id }}, {{ item.productId }}, {{ stockItemId }})"></i></label>
  86.                                                     {%- endfor -%}
  87.                                                 </div>
  88.                                             {%- endif -%}
  89.                                         {% endif %}
  90.                                     </div>
  91.                                     <div class="cart-content-price-box">
  92.                                         {% set isDiscounted = item.originalPrice  %}
  93.                                         {% if isDiscounted %}
  94.                                             <div class="cart-content-discounted-price main">{{ item.price | price(currency, precision) }}</div>
  95.                                             <div class="cart-content-original-price main">{{ item.originalPrice | price(currency, precision) }}</div>
  96.                                         {% else %}
  97.                                             <div class="cart-content-price main">{{ item.price | price(currency, precision) }}</div>
  98.                                         {% endif %}
  99.                                     </div>
  100.                                 </div>
  101.                                 {% if item.options %}
  102.                                     {% for option in item.options %}
  103.                                         <div class="row added-options mb-3 mb-md-0" data-option="{{ option.id }}">
  104.                                             <div class="option-wrapper">
  105.                                                 {%- set imageDirectory = 'windows 11' in option.value|lower ? 'theme/images/icon/windows_11.svg' : ('windows 10' in option.value|lower ? 'theme/images/icon/windows.svg' : option.image) -%}
  106.                                                 {% if option.model == 1780026 %}
  107.                                                     {% set imageDirectory = 'theme/images/1-year-warranty.svg' %}
  108.                                                 {% endif %}
  109.                                                 {% if option.model == 1780024 %}
  110.                                                     {% set imageDirectory = 'theme/images/2-year-warranty.svg' %}
  111.                                                 {% endif %}
  112.                                                 {% if option.model == 1780027 %}
  113.                                                     {% set imageDirectory = 'theme/images/3-year-warranty.svg' %}
  114.                                                 {% endif %}
  115.                                                 {%- if imageDirectory -%}
  116.                                                     {#<img loading="lazy" decoding="async" src="{{  asset(imageDirectory) }}" alt="{{ option.value }}" width="25" />#}
  117.                                                 {%- endif -%}
  118.                                                 <div class="option-info">
  119.                                                     {% if option.model %}
  120.                                                         <a href="{{ option.href }}" class="cart-content-product-name">
  121.                                                             {{- option.value -}}
  122.                                                         </a>
  123.                                                     {% else %}
  124.                                                         <a class="cart-content-product-name">
  125.                                                             {{- option.value -}}
  126.                                                         </a>
  127.                                                     {% endif %}
  128.                                                     <button class="remove remove-product" data-item="{{ item.id }}" data-loading-text="<i class='fas fa-spinner fa-spin' style='font-size: 18px; margin-left: 5px;'></i>" data-original-text="{{ 'Cart option remove text'|trans }}" data-option="{{ option.id }}">{{ 'Cart option remove text'|trans }}</button>
  129.                                                 </div>
  130.                                                 <div class="cart-content-price">
  131.                                                     {% set priceToShow = option.price ?: 0 %}
  132.                                                     {{ priceToShow | price(currency, precision) }}
  133.                                                 </div>
  134.                                             </div>
  135.                                         </div>
  136.                                     {% endfor %}
  137.                                 {% endif %}
  138.                             </div>
  139.                         {% endfor %}
  140.                         {% if removedItem is defined %}
  141.                             <div class="alert alert-warning mt-3 undo" role="alert">
  142.                                 <input type="hidden" name="removedItem" value="{{ removedItem|json_encode() }}">
  143.                                 <span><a href="{{ removedItem.href }}"><strong>{{ removedItem.productName }}</strong> </a>{{ 'was removed from cart' | trans }} <a id="undo-removed-item"><strong>{{ 'Undo.' | trans }}</strong></a></span>
  144.                             </div>
  145.                         {% endif %}
  146.                     </div>
  147.                     <div class="cart-content-middle">
  148.                         {#<div class="cart-content-line">
  149.                             <div class="row">
  150.                                 <div class="col-sm-6">
  151.                                     <span class="subtotal-text">{{ 'Subtotal' | trans }}:</span>
  152.                                 </div>
  153.                                 <div class="col-sm-6 text-end">
  154.                                     <span class="subtotal-price">{{ subTotal | price(currency, precision) }}</span>
  155.                                 </div>
  156.                             </div>
  157.                         </div>#}
  158.                         {% if estimation and defaultLocale != 'en' %}
  159.                             <div class="cart-content-line">
  160.                                 <div class="row shipping-cost">
  161.                                     <div class="col-sm-6">
  162.                                         {{ 'Shipping cost' | trans }}:
  163.                                     </div>
  164.                                     {% if shippingCost > 0 %}
  165.                                         <div class="col-sm-6 text-end">
  166.                                         {{ 'Estimation' | trans }}: {{ shippingCost | price(currency, precision) }}
  167.                                         </div>
  168.                                     {% else %}
  169.                                         <div class="col-sm-6 text-end price-free">
  170.                                         {% if domainId in [4,5] %}
  171.                                             {{ 'Please choose a shipping type' | trans }}
  172.                                         {% else %}
  173.                                             {{ 'Free' | trans }}
  174.                                         {% endif %}
  175.                                         </div>
  176.                                     {% endif %}
  177.                                 </div>
  178.                             </div>
  179.                         {% elseif defaultLocale != 'en' and shippingCost >= 0 and shippingIsSelected %}
  180.                             <div class="cart-content-line">
  181.                                 <div class="row shipping-cost">
  182.                                     <div class="col-sm-6">
  183.                                         <span class="shipping-price-text">{{ 'Shipping cost' | trans }}:</span>
  184.                                     </div>
  185.                                     {% if shippingCost > 0 %}
  186.                                         <div class="col-sm-6 text-end cart-content-price">
  187.                                             {{ shippingCost | price(currency, precision) }}
  188.                                         </div>
  189.                                     {% else %}
  190.                                         <div class="col-sm-6 text-end price-free">
  191.                                             {{ 'Free' | trans }}
  192.                                         </div>
  193.                                     {% endif %}
  194.                                 </div>
  195.                             </div>
  196.                         {% endif %}
  197.                         {%- if app.session.get('checkout')['paymentMethodId'] is defined and domainId not in [const('Domain::DOMAIN_ID_RT_EU'), const('Domain::DOMAIN_ID_WS_EU')] -%}
  198.                             <div class="cart-content-line">
  199.                                 <div class="row shipping-cost">
  200.                                     <div class="col-sm-6">
  201.                                         <span class="shipping-price-text">{{ 'Payment type' | trans }}:</span>
  202.                                     </div>
  203.                                     {% if cashOnDeliveryProductItem is defined %}
  204.                                         <div class="col-sm-6 text-end cart-content-price">
  205.                                             {{ cashOnDeliveryProductItem.price | price(currency, precision) }}
  206.                                         </div>
  207.                                     {% else %}
  208.                                         <div class="col-sm-6 text-end price-free">
  209.                                             {{ 'Free' | trans }}
  210.                                         </div>
  211.                                     {% endif %}
  212.                                 </div>
  213.                             </div>
  214.                         {% endif %}
  215.                         {% if discount > 0 or coupon != '' %}
  216.                             <div class="cart-content-line code-applied">
  217.                                 <div class="row shipping-cost">
  218.                                     <div class="col-7 col-sm-6 d-flex" style="font-size: 12px;">
  219.                                         {% if three_percent_partner_discount is defined and three_percent_partner_discount %}
  220.                                             {{ 'Payment type discount' | trans }}
  221.                                         {% else %}
  222.                                             {#<span>{{ 'Coupon code applied' | trans }}: {{ coupon }}</span><a id="coupon-remove" title="{{ 'Remove coupon' | trans }}"><i class="far fa-times ss"></i></a>#}
  223.                                             <label id="coupon-text">
  224.                                                 <span>{{ coupon }}</span>
  225.                                                 <a id="coupon-remove-m" title="{{ 'Remove coupon' | trans }}" data-remove-url="{{ path("cart_coupon_remove") }}"><i class="far fa-times"></i></a>
  226.                                             </label>
  227.                                         {% endif %}
  228.                                     </div>
  229.                                     <div class="col-5 col-sm-6 text-end" style="font-size: 12px; font-weight: 600; display: flex; align-items: center; justify-content: end;">
  230.                                         {% if discount > 0 %}
  231.                                             - {{ discount | price(currency, precision) }}
  232.                                         {% endif %}
  233.                                     </div>
  234.                                 </div>
  235.                             </div>
  236.                         {% endif %}
  237.                         <div class="cart-content-line">
  238.                             <div class="row">
  239.                                 <div class="col-7 col-sm-6">
  240.                                     <span class="total-text">
  241.                                         {{ 'Total price' | trans }}
  242.                                         {% if app.session.has('useZeroVat') and app.session.get('useZeroVat') %}
  243.                                             ({{- 'Cart price without vat text' | trans -}}):
  244.                                         {% else %}
  245.                                             ({{-'Cart price with vat text' | trans-}}):
  246.                                         {% endif %}
  247.                                     </span>
  248.                                 </div>
  249.                                 <div class="col-5 col-sm-6 text-end">
  250.                                     <span class="total-price">{{ total | price(currency, precision) }}</span>
  251.                                 </div>
  252.                             </div>
  253.                         </div>
  254.                         {% if not shippingIsSelected %}
  255.                             <div class="cart-content-line">
  256.                                 <div class="alert alert-info delivery-price-info mb-0" role="alert">
  257.                                     {% set currentDate = "now"|date('Ymd') %}
  258.                                     {% if cartIncludesOnlyMainProductTypeItem and defaultLocale != 'en' and freeShipping is defined and  freeShipping == true %}
  259.                                         {{ 'Product delivery info free'|trans }}
  260.                                     {% else %}
  261.                                         {{- 'Cart delivery info' |trans({ "title": shippingTitle, "price": shippingCost |price('', precision), 'locale': defaultLocale }) | replace({',00':''}) | raw -}}
  262.                                     {% endif %}
  263.                                 </div>
  264.                             </div>
  265.                         {% endif %}
  266.                     </div>
  267.                     <div class="cart-content-bottom">
  268.                         <div class="cart-content-line">
  269.                             <div class="row">
  270.                                 <div class="col-12 col-md-6">
  271.                                     <div class="coupon-wrapper">
  272.                                         <h3 class="coupon-header">{{ 'Enter coupon code' | trans }}:</h3>
  273.                                         <a class="coupon-header-toggle collapsed" data-bs-toggle="collapse" href="#couponCode" role="button" aria-expanded="true" aria-controls="couponCode"><span>{{- 'Enter coupon code' | trans -}}</span><i class="fas fa-chevron-down ms-2"></i></a>
  274.                                         <div class="collapse collapse-content" id="couponCode">
  275.                                             <div class="coupon-code-wrapper">
  276.                                                 <input type="text" value="{{ coupon }}" name="coupon" id="coupon-code" placeholder="{{ 'Coupon code' | trans | lower }}" class="coupon-code-text">
  277.                                                 <button type="button" name="" id="apply-code-cart" class="btn furbify-button" data-loading-text="{{ 'Loading' | trans }}">{{ 'Apply code' | trans }}</button>
  278.                                             </div>
  279.                                         </div>
  280.                                     </div>
  281.                                 </div>
  282.                                 <div class="col-12 col-md-6 checkout-button-wrapper">
  283.                                     <div class="cart-buttons">
  284.                                         <a class="btn btn-primary btn-product btn-checkout text-nowrap btn-back"
  285.                                            href="{{ cartBackToProductsLink }}">
  286.                                                 <i class="far fa-chevron-left"></i><span style="margin-left: 20px">{{ 'Back' | trans }}</span></a>
  287.                                         <a href="{{ path('checkout_customer') }}" class="btn btn-primary btn-product btn-checkout text-nowrap" style="border-radius: 6px;" data-loading-text="<i class='fas fa-spinner fa-spin'></i> {{ 'Loading' | trans }}"><span>{{ 'Proceed to checkout' | trans }}</span><i class="far fa-chevron-right"></i></a>
  288.                                     </div>
  289.                                 </div>
  290.                             </div>
  291.                         </div>
  292.                     </div>
  293.                 </div>
  294.             {% else %}
  295.                 <div class="cart-content">
  296.                     <div class="cart-content-top">
  297.                         <div class="cart-content-line">
  298.                             <div class="row">
  299.                                 <div class="cart-heading">
  300.                                     <h1>{{ 'Shopping cart' | trans }}</h1>
  301.                                 </div>
  302.                                 <div class="cart-content-back">
  303.                                     <a href="{{ path('homepage') }}">{{ 'Back to shopping' | trans }}</a>
  304.                                 </div>
  305.                             </div>
  306.                         </div>
  307.                         {% if removedItem is defined %}
  308.                             <div class="alert alert-warning mt-3 undo" role="alert">
  309.                                 <input type="hidden" name="removedItem" value="{{ removedItem|json_encode() }}">
  310.                                 <span><a href="{{ removedItem.href }}"><strong>{{ removedItem.productName }}</strong> </a>{{ 'was removed from cart' | trans }} <a id="undo-removed-item"><strong>{{ 'Undo.' | trans }}</strong></a></span>
  311.                             </div>
  312.                         {% elseif loginError is defined %}
  313.                             <div class="alert alert-danger mt-3 login-error" role="alert">
  314.                                 <p>{{ loginError.alertText|trans|raw }}</p>
  315.                                 {%- if loginError.signInRequired is defined -%}
  316.                                     <a id="log-out-and-log-in-customer" class="btn log-out">{{ 'Logout'|trans }}</a>
  317.                                 {%- else -%}
  318.                                     <a id="log-out-customer-and-reload" class="btn log-out">{{ 'Logout'|trans }}</a>
  319.                                 {%- endif -%}
  320.                             </div>
  321.                         {% else %}
  322.                             <div class="alert alert-warning mt-3" role="alert">
  323.                                 {{ 'Your shopping cart is empty' | trans }}
  324.                             </div>
  325.                         {% endif %}
  326.                     </div>
  327.                 </div>
  328.             {% endif %}
  329.             <div class="row">
  330.                 <div class="col-sm-12 text-center pb-4 mb-2">
  331.                     <strong>{{ 'Need assistance? Call' | trans }}<br><a href="tel:{{ phone_support }}">{{ phone_support }}</a></strong><br/>
  332.                     <small>({{ 'on workdays' | trans }} 8:00 - 16:30)</small>
  333.                 </div>
  334.             </div>
  335.             {{ include(template_from_string(contentBottom)) }}
  336.         </div>
  337.     </div>
  338. {% endblock %}
  339. {% block dataLayer %}
  340.     {% if app.environment == 'prod' %}
  341.         <script>
  342.             window.dataLayer = window.dataLayer || [];
  343.             dataLayer.push({ ecommerce: null });
  344.             dataLayer.push({
  345.                 event: 'view_cart', 
  346.                 ecommerce: {
  347.                     currency: '{{ currency_ISO }}', 
  348.                     value: '{{ total }}', 
  349.                     items: [ {{ marketingProductsGA4 |raw }} ]
  350.                 }
  351.             });
  352.         </script>
  353.     {% endif %}
  354. {% endblock %}
  355. {% block title %}{{ 'Shopping cart' | trans }} | {{ parent() }}{% endblock %}
  356. {% block robots %}
  357.     {% if 
  358.         ( domainId in [ const('Domain::DOMAIN_ID_RT_SK'), const('Domain::DOMAIN_ID_WS_SK') ] and app.request.locale != 'sk' ) or 
  359.         ( domainId in [ const('Domain::DOMAIN_ID_RT_HU'), const('Domain::DOMAIN_ID_WS_HU') ] and app.request.locale != 'hu' ) or 
  360.         ( domainId in [ const('Domain::DOMAIN_ID_RT_CZ'), const('Domain::DOMAIN_ID_WS_CZ') ] and app.request.locale != 'cz' ) or 
  361.         ( domainId in [ const('Domain::DOMAIN_ID_RT_EU'), const('Domain::DOMAIN_ID_WS_EU') ] and app.request.locale != 'en' ) 
  362.     %}
  363.         <meta name="robots" content="noindex, nofollow, noarchive">
  364.     {% else %}
  365.         <meta name="robots" content="noindex">
  366.     {% endif %}
  367. {% endblock %}
  368. {% block bodyClass %}checkout-body-bg{% endblock %}
  369. {% block header %}
  370.     {{ include(template_from_string(header)) }}
  371. {% endblock %}
  372. {% block footer %}
  373.     {{ include(template_from_string(footer)) }}
  374. {% endblock %}
  375. {% block javascripts %}
  376.     {{ parent() }}
  377.     <script type="text/javascript" src="{{ asset('theme/owl-carousel/owl.carousel.min.js'|appendAssetCache) }}"></script>
  378.     <script type="text/javascript">
  379.         var couponCodeCheckUrl = '{{ path("cart_coupon") }}';
  380.         function stockItemRemove (basketItemId, productId, stockItemCode) {
  381.             $.ajax({
  382.                 url: '{{ path("product_stock_item_remove") }}',
  383.                 data: { basketItemId, productId, stockItemCode },
  384.                 success: function(json) {
  385.                     if (json.status === 'succes') {
  386.                         location.reload();
  387.                     }
  388.                 }
  389.             });
  390.         }
  391.         if (document.querySelector('.cart-content-top .alert-success')) {
  392.             setTimeout(() => {
  393.                 document.querySelector('.cart-content-top .alert-success').remove();
  394.             }, 5000);
  395.         }
  396.         if (document.getElementById('couponCode')) {
  397.             if (document.body.clientWidth > 685) {
  398.                 document.getElementById('couponCode').classList.add('show');
  399.             } else {
  400.                 document.getElementById('couponCode').classList.remove('show');
  401.             }
  402.         }
  403.         $('.cart-content-line').on('click', '.remove', function() {
  404.             removeCartContentLine(this);
  405.         });
  406.         function removeCartContentLine (element) {
  407.             updateButton('loading', element);
  408.             $.ajax({
  409.                 url: '{{ path("cart_remove") }}',
  410.                 type: 'post',
  411.                 data: {
  412.                     item: element.dataset.item,
  413.                     option: element.dataset.option,
  414.                     productName: element.dataset.name,
  415.                     productId: element.dataset.productId
  416.                 },
  417.                 dataType: 'json',
  418.                 beforeSend: function() {
  419.                     $('.steps-content-box a, .cart-content-back a, .plus, .minus, .remove, .btn-checkout, input').prop('disabled', true);
  420.                 },
  421.                 success: function(json) {
  422.                     if ( parseInt(element.dataset.option) == 0 ) {
  423.                         gtag('event', 'remove_from_cart', { "items": [{ "id": element.dataset.productId, "name": element.dataset.name }]});
  424.                     }
  425.                     setTimeout(function () {
  426.                         location.reload();
  427.                     }, 100);
  428.                 }
  429.             });
  430.         }
  431.         // cart: clear removed array
  432.         $.ajax({url: '{{ path("cart_clear_removed_array") }}', type: 'get' });
  433.         $('#undo-removed-item').on('click', function(e) {
  434.             var removedItem = JSON.parse($('input[name=removedItem]').val());
  435.             var attributeOptions = [];
  436.             removedItem.attributes.forEach(element => {
  437.                 attributeOptions.push(element.attribute_option)
  438.             });
  439.             let postData = {
  440.                 product_id: removedItem.productId,
  441.                 option: attributeOptions,
  442.                 quantity: removedItem.quantity,
  443.                 stockItems: (removedItem.stockItemCodes ?? false)
  444.             }
  445.             $.ajax({
  446.                 url: '{{ path("cart_add") }}',
  447.                 type: 'post',
  448.                 data: postData,
  449.                 dataType: 'json',
  450.                 success: function(json) {
  451.                     if ( json['error'] ) {
  452.                         $('#notification').html(json['error']).modal('show');
  453.                     }
  454.                     if ( json['success'] ) {
  455.                         $.ajax({
  456.                             url: '{{ path("cart_remove_last_removed") }}',
  457.                             type: 'post',
  458.                             data: { product_id: removedItem.productId },
  459.                             dataType: 'json',
  460.                             success: function(json) {
  461.                                 if ( json['success'] == false ) {
  462.                                     $('#notification').html(json['error']).modal('show');
  463.                                     return;
  464.                                 }
  465.                                 gtag('event', 'add_to_cart', { "items": [{ "id": removedItem.productId, "name": json['gtag'].brand + ' ' + json['gtag'].title, "brand": json['gtag'].brand, "category": json['gtag'].type, "quantity": removedItem.quantity, "price": json['gtag'].price }]});
  466.                                 setTimeout(function () {
  467.                                     location.reload();
  468.                                 }, 100);
  469.                             }
  470.                         });
  471.                     }
  472.                 }
  473.             });
  474.         });
  475.         $('.cart-content-line .product-quantity').on('click', '.plus', function() {
  476.             var self = this;
  477.             var quantity = parseInt($('input[data-id="' + $(this).data('id') + '"]').val()) + 1;
  478.             $.ajax({
  479.                 url: '{{ path("cart_update") }}',
  480.                 type: 'POST',
  481.                 data: { item: $(self).data('id'), quantity: quantity },
  482.                 dataType: 'json',
  483.                 beforeSend: function() {
  484.                     $('.steps-content-box a, .cart-content-back a, .plus, .minus, .remove, .btn-checkout, input').prop('disabled', true);
  485.                     $(self).button('loading');
  486.                 },
  487.                 success: function(json) {
  488.                     $(".alert:not('.delivery-price-info'), .text-danger").remove();
  489.                     if ( json.error){
  490.                         if (json.error.length > 0) {
  491.                             $('.cart-content-top .cart-content-line:first-child').after('<div class="alert alert-danger mt-3" role="alert">{{ 'Products marked with *** has an order quantity limit' | trans }}</div>');
  492.                             for (i in json.error) {
  493.                                 $('.cart-content-line[data-id="' + json.error[i] + '"] .cart-content-product-name.main').append('<span class="text-danger">***</span>')
  494.                             }
  495.                         }
  496.                     } else if ( json.redirect ) {
  497.                         location = json.redirect;
  498.                         return;
  499.                     } else if ( json.product ) {
  500.                         $('.cart-content-line[data-id="' + json.product.id + '"] .product-quantity input').val(json.product.quantity);
  501.                         if ( json.product.originalPrice != '0' ) {
  502.                             $('.cart-content-line[data-id="' + json.product.id + '"] .cart-content-original-price.main').html(json.product.originalPrice);
  503.                             $('.cart-content-line[data-id="' + json.product.id + '"] .cart-content-discounted-price.main').html(json.product.price);
  504.                         } else {
  505.                             $('.cart-content-line[data-id="' + json.product.id + '"] .cart-content-price.main').html(json.product.price);
  506.                         }
  507.                         if ( json.product.options ) {
  508.                             for ( i in json.product.options ) {
  509.                                 $('.cart-content-line[data-id="' + json.product.id + '"] .added-options[data-option="' + json.product.options[i].id + '"] .cart-content-price').html(json.product.options[i].price);
  510.                             }
  511.                         }
  512.                     }
  513.                     if ( json.subTotal ) {
  514.                         $('.cart-content-middle .subtotal-price').html(json.subTotal);
  515.                     }
  516.                     if ( json.discount ) {
  517.                         $('.cart-content-middle .code-applied .text-end').html(json.discount);
  518.                     }
  519.                     if ( json.total ) {
  520.                         $('.cart-content-middle .total-price').html(json.total);
  521.                     }
  522.                     if ( json.stock ) {
  523.                         if ( json.stock.length > 0 ) {
  524.                             $('.cart-content-top .cart-content-line:first-child').after('<div class="alert alert-danger mt-3" role="alert">{{ 'Products marked with *** are not available in the desired quantity or not in stock' | trans }}</div>');
  525.                             for ( i in json.stock ) {
  526.                                 $('.cart-content-line[data-id="' + json.stock[i] + '"] .cart-content-product-name.main').append('<span class="text-danger">***</span>')
  527.                             }
  528.                         }
  529.                     }
  530.                     $('.steps-content-box a, .cart-content-back a, .plus, .minus, .remove, .btn-checkout, input').prop('disabled', false);
  531.                     $(self).button('reset');
  532.                 }
  533.             });
  534.         });
  535.         $('.cart-content-line .product-quantity').on('click', '.minus', function() {
  536.             var self = this;
  537.             var quantity = parseInt($('input[data-id="' + $(this).data('id') + '"]').val()) - 1;
  538.             if ( quantity < 1 ) {
  539.                 removeCartContentLine($('.remove-product', $(this).parent().parent().parent().parent())[0]);
  540.                 return;
  541.             }
  542.             $.ajax({
  543.                 url: '{{ path("cart_update") }}',
  544.                 type: 'POST',
  545.                 data: { item: $(this).data('id'), quantity: quantity },
  546.                 dataType: 'json',
  547.                 beforeSend: function() {
  548.                     $('.steps-content-box a, .cart-content-back a, .plus, .minus, .remove, .btn-checkout, input').prop('disabled', true);
  549.                     $(self).button('loading');
  550.                 },
  551.                 success: function(json) {
  552.                     $(".alert:not('.delivery-price-info'), .text-danger").remove();
  553.                     if ( json.redirect ) {
  554.                         location = json.redirect;
  555.                         return;
  556.                     } else if ( json.product ) {
  557.                         $('.cart-content-line[data-id="' + json.product.id + '"] .product-quantity input').val(json.product.quantity);
  558.                         if ( json.product.originalPrice != '0' ) {
  559.                             $('.cart-content-line[data-id="' + json.product.id + '"] .cart-content-original-price.main').html(json.product.originalPrice);
  560.                             $('.cart-content-line[data-id="' + json.product.id + '"] .cart-content-discounted-price.main').html(json.product.price);
  561.                         } else {
  562.                             $('.cart-content-line[data-id="' + json.product.id + '"] .cart-content-price.main').html(json.product.price);
  563.                         }
  564.                         if ( json.product.options ) {
  565.                             for ( i in json.product.options ) {
  566.                                 $('.cart-content-line[data-id="' + json.product.id + '"] .added-options[data-option="' + json.product.options[i].id + '"] .cart-content-price').html(json.product.options[i].price);
  567.                             }
  568.                         }
  569.                     }
  570.                     if ( json.subTotal ) {
  571.                         $('.cart-content-middle .subtotal-price').html(json.subTotal);
  572.                     }
  573.                     if ( json.discount ) {
  574.                         $('.cart-content-middle .code-applied .text-end').html(json.discount);
  575.                     }
  576.                     if ( json.total ) {
  577.                         $('.cart-content-middle .total-price').html(json.total);
  578.                     }
  579.                     if ( json.stock ) {
  580.                         if ( json.stock.length > 0 ) {
  581.                             $('.cart-content-top .cart-content-line:first-child').after('<div class="alert alert-danger mt-3" role="alert">{{ 'Products marked with *** are not available in the desired quantity or not in stock' | trans }}</div>');
  582.                             for ( i in json.stock ) {
  583.                                 $('.cart-content-line[data-id="' + json.stock[i] + '"] .cart-content-product-name.main').append('<span class="text-danger">***</span>')
  584.                             }
  585.                         }
  586.                     }
  587.                     $('.steps-content-box a, .cart-content-back a, .plus, .minus, .remove, .btn-checkout, input').prop('disabled', false);
  588.                     $(self).button('reset');
  589.                 }
  590.             });
  591.         });
  592.         $('.cart-content-line .product-quantity').on('keyup', 'input', function() {
  593.             var self = this;
  594.             var quantity = parseInt($(this).val());
  595.             if ( quantity < 1 ) {
  596.                 return;
  597.             }
  598.             $.ajax({
  599.                 url: '{{ path("cart_update") }}',
  600.                 type: 'POST',
  601.                 data: { item: $(this).data('id'), quantity: quantity },
  602.                 dataType: 'json',
  603.                 beforeSend: function() {
  604.                     $('.steps-content-box a, .cart-content-back a, .plus, .minus, .remove, .btn-checkout, input').prop('disabled', true);
  605.                     $(self).button('loading');
  606.                 },
  607.                 success: function(json) {
  608.                     $(".alert:not('.delivery-price-info'), .text-danger").remove();
  609.                     if ( json.redirect ) {
  610.                         location = json.redirect;
  611.                         return;
  612.                     } else if ( json.product ) {
  613.                         $('.cart-content-line[data-id="' + json.product.id + '"] .product-quantity input').val(json.product.quantity);
  614.                         if ( json.product.originalPrice > 0 ) {
  615.                             $('.cart-content-line[data-id="' + json.product.id + '"] .cart-content-original-price.main').html(json.product.originalPrice);
  616.                             $('.cart-content-line[data-id="' + json.product.id + '"] .cart-content-discounted-price.main').html(json.product.price);
  617.                         } else {
  618.                             $('.cart-content-line[data-id="' + json.product.id + '"] .cart-content-price.main').html(json.product.price);
  619.                         }
  620.                         if ( json.product.options ) {
  621.                             for ( i in json.product.options ) {
  622.                                 $('.cart-content-line[data-id="' + json.product.id + '"] .added-options[data-option="' + json.product.options[i].id + '"] .cart-content-price').html(json.product.options[i].price);
  623.                             }
  624.                         }
  625.                     }
  626.                     if ( json.subTotal ) {
  627.                         $('.cart-content-middle .subtotal-price').html(json.subTotal);
  628.                     }
  629.                     if ( json.discount ) {
  630.                         $('.cart-content-middle .code-applied .text-end').html(json.discount);
  631.                     }
  632.                     if ( json.total ) {
  633.                         $('.cart-content-middle .total-price').html(json.total);
  634.                     }
  635.                     if ( json.stock ) {
  636.                         if ( json.stock.length > 0 ) {
  637.                             $('.cart-content-top .cart-content-line:first-child').after('<div class="alert alert-danger mt-3" role="alert">{{ "Products marked with *** are not available in the desired quantity or not in stock" | trans }}</div>');
  638.                             for ( i in json.stock ) {
  639.                                 $('.cart-content-line[data-id="' + json.stock[i] + '"] .cart-content-product-name.main').append('<span class="text-danger">***</span>')
  640.                             }
  641.                         }
  642.                     }
  643.                     $('.steps-content-box a, .cart-content-back a, .plus, .minus, .remove, .btn-checkout, input').prop('disabled', false);
  644.                     $(self).button('reset');
  645.                 }
  646.             });
  647.         });
  648.         $(document).on('click', '#apply-code-cart', function() {
  649.             var self = this;
  650.             $.ajax({
  651.                 url: '{{ path("cart_coupon") }}',
  652.                 type: 'POST',
  653.                 data: { coupon: $('#coupon-code').val() },
  654.                 dataType: 'json',
  655.                 beforeSend: function() {
  656.                     $('.steps-content-box a, .cart-content-back a, .plus, .minus, .remove, .btn-checkout, input').prop('disabled', true)
  657.                     $(self).button('loading')
  658.                 },
  659.                 success: function(json) {
  660.                     $('.error-text').remove();
  661.                     if ( json.error ) {
  662.                         $(self).parent().after('<div class="error-text col-12 float-start mt-1"><span>' + json.error + '</span></div>');
  663.                         document.querySelector('#coupon-code').style.backgroundColor = '#f6e6e7';
  664.                         document.querySelector('#coupon-code').style.color = '#e25868';
  665.                         $('.steps-content-box a, .cart-content-back a, .plus, .minus, .remove, .btn-checkout, input').prop('disabled', false);
  666.                         $(self).button('reset');
  667.                         return;
  668.                     }
  669.                     location.reload();
  670.                 }
  671.             });
  672.         });
  673.         {% if loginError is defined %}
  674.             {% if loginError.signInRequired is defined %}
  675.                 document.getElementById('log-out-and-log-in-customer').addEventListener('click', () => {
  676.                     ajax.get(
  677.                         "{{ path('customer_logout') }}"
  678.                     );
  679.                 });
  680.             {% else %}
  681.                 document.getElementById('log-out-customer-and-reload').addEventListener('click', () => {
  682.                     ajax.get(
  683.                         "{{ path('customer_logout') }}",
  684.                         {},
  685.                         () => {
  686.                             location.reload();
  687.                         }
  688.                     );
  689.                 });
  690.             {% endif %}
  691.         {% endif %}
  692.         $(document).on('click', '#coupon-remove', function() {
  693.             $.ajax({
  694.                 url: '{{ path("cart_coupon_remove") }}',
  695.                 type: 'POST',
  696.                 dataType: 'json',
  697.                 success: function(json) {
  698.                     $('.cart-content-line.code-applied').remove()
  699.                     location.reload();
  700.                 }
  701.             });
  702.         });
  703.     //--!></script>
  704.     {% if expire is defined %}
  705.         <script type="text/javascript">
  706.             var countDownDate = new Date('{{ expire }}').getTime();
  707.             var counter = setInterval(function() {
  708.                 var now = new Date().getTime();
  709.                 var distance = countDownDate - now;
  710.                 var hours = Math.floor(( distance % ( 1000 * 60 * 60 * 24 )) / ( 1000 * 60 * 60 ));
  711.                 if ( hours < 10 ) {
  712.                     hours = '0' + hours;
  713.                 }
  714.                 var minutes = Math.floor(( distance % ( 1000 * 60 * 60 )) / ( 1000 * 60 ));
  715.                 if ( minutes < 10 ) {
  716.                     minutes = '0' + minutes;
  717.                 }
  718.                 var seconds = Math.floor(( distance % ( 1000 * 60 )) / 1000 );
  719.                 if ( seconds < 10 ) {
  720.                     seconds = '0' + seconds;
  721.                 }
  722.                 if ( document.getElementById("basket-expire") !== null ) {
  723.                     document.getElementById("basket-expire").innerHTML = hours + ':' + minutes + ':' + seconds;
  724.                     if ( distance < 0 ) {
  725.                         clearInterval(counter);
  726.                         document.getElementById("basket-expire").innerHTML = '{{ 'Expired' | trans }}';
  727.                     }
  728.                 }
  729.             }, 1000);
  730.         //--!></script>
  731.     {% endif %}
  732. {% endblock %}