{% extends 'AtechNetCoreBundle/base.html.twig' %}
{% import "AtechNetCoreBundle/macros.html.twig" as macros %}
{% block content %}
{% set defaultLocale = app.request.session.get('defaultLocale') %}
<style>
.btn-back {
border-radius: 6px;
margin-right: 5px;
padding-left: 5px;
}
</style>
<div class="main-content checkout">
<div class="container">
{{ macros.printChceckoutSteps(stepsOptions) }}
{% if items is defined and items | length > 0 %}
<div class="cart-content">
<div class="cart-content-top">
<div class="cart-content-line">
<div class="heading-wrapper">
<div class="cart-heading">
<h1>{{ 'Shopping cart' | trans }}</h1>
</div>
</div>
</div>
{% if not stock %}
<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>
{% endif %}
{% for message in app.flashes('success') %}
<div class="alert alert-success" role="alert">
<i class="fa fa-check"></i>
<span>{{ message }}</span>
</div>
{% endfor %}
{% set cartIncludesOnlyMainProductTypeItem = false %}
{% for item in items %}
{%- set cartIncludesOnlyMainProductTypeItem = item.typeId in [
const('ProductType::PRODUCT_TYPE_ID_MONITOR'),
const('ProductType::PRODUCT_TYPE_ID_NOTEBOOK'),
const('ProductType::PRODUCT_TYPE_ID_PC'),
const('ProductType::PRODUCT_TYPE_ID_PC_SET'),
const('ProductType::PRODUCT_TYPE_ID_ALL_IN_ONE'),
const('ProductType::PRODUCT_TYPE_ID_TABLET'),
const('ProductType::PRODUCT_TYPE_ID_SMARTPHONE')
]
-%}
<div class="cart-content-line" data-id="{{ item.id }}">
<div class="row" style="margin-bottom: 4px;">
<div class="image-wrapper">
{% if item.image %}
<img loading="lazy" decoding="async" src="{{ item.image }}" alt="{{ item.name }}" width="57" height="43" />
{% endif %}
</div>
<div class="col-6 col-sm-6 col-lg-5 info-wrapper">
<a href="{{ item.href }}" class="cart-content-product-name main">{{- item.name -}}{%- if not item.stock -%}<span class="text-danger">***</span>{%- endif -%}</a>
<p class="cart-content-product-desc">
{{ item.description|replace({
'Gold': ('grades.A')|trans,
'Silver': ('grades.B')|trans,
'Bronze': ('grades.C')|trans,
}) }}
</p>
{% if item.stock %}
<p class="cart-content-in-stock-text">{{ 'Cart item in stock text'|trans }}</p>
{% endif %}
<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>
</div>
<div class="col-6 col-lg-4 quantity-wrapper">
{% if item.productId != const('Product::SUMMER_2026_COUPON_GIFT_ITEM_ID') and item.productId != const('Product::PEXESO_SCHOOL_GIFT_ITEM_ID') %}
{%- set stockItemCodes = app.session.get('stockItemCodes') -%}
{%- if stockItemCodes[item.productId] is not defined -%}
<div class="qty-and-remove">
<div class="product-quantity{% if domainId == 7 %} wide-product-quantity{% endif %}">
<input type="text" value="{{ item.quantity }}" data-id="{{ item.id }}" autocomplete="off" aria-label="{{ "Product quantity"|trans }}">
<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>
<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>
</div>
</div>
{%- endif -%}
{%- if stockItemCodes and stockItemCodes[item.productId] is defined -%}
<div class="serial-numbers w-100 d-flex flex-row flex-wrap">
<p class="mb-1 col-12">{{ 'Serial numbers'|trans }}:</p>
{%- for stockItemId in stockItemCodes[item.productId] -%}
<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>
{%- endfor -%}
</div>
{%- endif -%}
{% endif %}
</div>
<div class="cart-content-price-box">
{% set isDiscounted = item.originalPrice %}
{% if isDiscounted %}
<div class="cart-content-discounted-price main">{{ item.price | price(currency, precision) }}</div>
<div class="cart-content-original-price main">{{ item.originalPrice | price(currency, precision) }}</div>
{% else %}
<div class="cart-content-price main">{{ item.price | price(currency, precision) }}</div>
{% endif %}
</div>
</div>
{% if item.options %}
{% for option in item.options %}
<div class="row added-options mb-3 mb-md-0" data-option="{{ option.id }}">
<div class="option-wrapper">
{%- 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) -%}
{% if option.model == 1780026 %}
{% set imageDirectory = 'theme/images/1-year-warranty.svg' %}
{% endif %}
{% if option.model == 1780024 %}
{% set imageDirectory = 'theme/images/2-year-warranty.svg' %}
{% endif %}
{% if option.model == 1780027 %}
{% set imageDirectory = 'theme/images/3-year-warranty.svg' %}
{% endif %}
{%- if imageDirectory -%}
{#<img loading="lazy" decoding="async" src="{{ asset(imageDirectory) }}" alt="{{ option.value }}" width="25" />#}
{%- endif -%}
<div class="option-info">
{% if option.model %}
<a href="{{ option.href }}" class="cart-content-product-name">
{{- option.value -}}
</a>
{% else %}
<a class="cart-content-product-name">
{{- option.value -}}
</a>
{% endif %}
<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>
</div>
<div class="cart-content-price">
{% set priceToShow = option.price ?: 0 %}
{{ priceToShow | price(currency, precision) }}
</div>
</div>
</div>
{% endfor %}
{% endif %}
</div>
{% endfor %}
{% if removedItem is defined %}
<div class="alert alert-warning mt-3 undo" role="alert">
<input type="hidden" name="removedItem" value="{{ removedItem|json_encode() }}">
<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>
</div>
{% endif %}
</div>
<div class="cart-content-middle">
{#<div class="cart-content-line">
<div class="row">
<div class="col-sm-6">
<span class="subtotal-text">{{ 'Subtotal' | trans }}:</span>
</div>
<div class="col-sm-6 text-end">
<span class="subtotal-price">{{ subTotal | price(currency, precision) }}</span>
</div>
</div>
</div>#}
{% if estimation and defaultLocale != 'en' %}
<div class="cart-content-line">
<div class="row shipping-cost">
<div class="col-sm-6">
{{ 'Shipping cost' | trans }}:
</div>
{% if shippingCost > 0 %}
<div class="col-sm-6 text-end">
{{ 'Estimation' | trans }}: {{ shippingCost | price(currency, precision) }}
</div>
{% else %}
<div class="col-sm-6 text-end price-free">
{% if domainId in [4,5] %}
{{ 'Please choose a shipping type' | trans }}
{% else %}
{{ 'Free' | trans }}
{% endif %}
</div>
{% endif %}
</div>
</div>
{% elseif defaultLocale != 'en' and shippingCost >= 0 and shippingIsSelected %}
<div class="cart-content-line">
<div class="row shipping-cost">
<div class="col-sm-6">
<span class="shipping-price-text">{{ 'Shipping cost' | trans }}:</span>
</div>
{% if shippingCost > 0 %}
<div class="col-sm-6 text-end cart-content-price">
{{ shippingCost | price(currency, precision) }}
</div>
{% else %}
<div class="col-sm-6 text-end price-free">
{{ 'Free' | trans }}
</div>
{% endif %}
</div>
</div>
{% endif %}
{%- if app.session.get('checkout')['paymentMethodId'] is defined and domainId not in [const('Domain::DOMAIN_ID_RT_EU'), const('Domain::DOMAIN_ID_WS_EU')] -%}
<div class="cart-content-line">
<div class="row shipping-cost">
<div class="col-sm-6">
<span class="shipping-price-text">{{ 'Payment type' | trans }}:</span>
</div>
{% if cashOnDeliveryProductItem is defined %}
<div class="col-sm-6 text-end cart-content-price">
{{ cashOnDeliveryProductItem.price | price(currency, precision) }}
</div>
{% else %}
<div class="col-sm-6 text-end price-free">
{{ 'Free' | trans }}
</div>
{% endif %}
</div>
</div>
{% endif %}
{% if discount > 0 or coupon != '' %}
<div class="cart-content-line code-applied">
<div class="row shipping-cost">
<div class="col-7 col-sm-6 d-flex" style="font-size: 12px;">
{% if three_percent_partner_discount is defined and three_percent_partner_discount %}
{{ 'Payment type discount' | trans }}
{% else %}
{#<span>{{ 'Coupon code applied' | trans }}: {{ coupon }}</span><a id="coupon-remove" title="{{ 'Remove coupon' | trans }}"><i class="far fa-times ss"></i></a>#}
<label id="coupon-text">
<span>{{ coupon }}</span>
<a id="coupon-remove-m" title="{{ 'Remove coupon' | trans }}" data-remove-url="{{ path("cart_coupon_remove") }}"><i class="far fa-times"></i></a>
</label>
{% endif %}
</div>
<div class="col-5 col-sm-6 text-end" style="font-size: 12px; font-weight: 600; display: flex; align-items: center; justify-content: end;">
{% if discount > 0 %}
- {{ discount | price(currency, precision) }}
{% endif %}
</div>
</div>
</div>
{% endif %}
<div class="cart-content-line">
<div class="row">
<div class="col-7 col-sm-6">
<span class="total-text">
{{ 'Total price' | trans }}
{% if app.session.has('useZeroVat') and app.session.get('useZeroVat') %}
({{- 'Cart price without vat text' | trans -}}):
{% else %}
({{-'Cart price with vat text' | trans-}}):
{% endif %}
</span>
</div>
<div class="col-5 col-sm-6 text-end">
<span class="total-price">{{ total | price(currency, precision) }}</span>
</div>
</div>
</div>
{% if not shippingIsSelected %}
<div class="cart-content-line">
<div class="alert alert-info delivery-price-info mb-0" role="alert">
{% set currentDate = "now"|date('Ymd') %}
{% if cartIncludesOnlyMainProductTypeItem and defaultLocale != 'en' and freeShipping is defined and freeShipping == true %}
{{ 'Product delivery info free'|trans }}
{% else %}
{{- 'Cart delivery info' |trans({ "title": shippingTitle, "price": shippingCost |price('', precision), 'locale': defaultLocale }) | replace({',00':''}) | raw -}}
{% endif %}
</div>
</div>
{% endif %}
</div>
<div class="cart-content-bottom">
<div class="cart-content-line">
<div class="row">
<div class="col-12 col-md-6">
<div class="coupon-wrapper">
<h3 class="coupon-header">{{ 'Enter coupon code' | trans }}:</h3>
<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>
<div class="collapse collapse-content" id="couponCode">
<div class="coupon-code-wrapper">
<input type="text" value="{{ coupon }}" name="coupon" id="coupon-code" placeholder="{{ 'Coupon code' | trans | lower }}" class="coupon-code-text">
<button type="button" name="" id="apply-code-cart" class="btn furbify-button" data-loading-text="{{ 'Loading' | trans }}">{{ 'Apply code' | trans }}</button>
</div>
</div>
</div>
</div>
<div class="col-12 col-md-6 checkout-button-wrapper">
<div class="cart-buttons">
<a class="btn btn-primary btn-product btn-checkout text-nowrap btn-back"
href="{{ cartBackToProductsLink }}">
<i class="far fa-chevron-left"></i><span style="margin-left: 20px">{{ 'Back' | trans }}</span></a>
<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>
</div>
</div>
</div>
</div>
</div>
</div>
{% else %}
<div class="cart-content">
<div class="cart-content-top">
<div class="cart-content-line">
<div class="row">
<div class="cart-heading">
<h1>{{ 'Shopping cart' | trans }}</h1>
</div>
<div class="cart-content-back">
<a href="{{ path('homepage') }}">{{ 'Back to shopping' | trans }}</a>
</div>
</div>
</div>
{% if removedItem is defined %}
<div class="alert alert-warning mt-3 undo" role="alert">
<input type="hidden" name="removedItem" value="{{ removedItem|json_encode() }}">
<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>
</div>
{% elseif loginError is defined %}
<div class="alert alert-danger mt-3 login-error" role="alert">
<p>{{ loginError.alertText|trans|raw }}</p>
{%- if loginError.signInRequired is defined -%}
<a id="log-out-and-log-in-customer" class="btn log-out">{{ 'Logout'|trans }}</a>
{%- else -%}
<a id="log-out-customer-and-reload" class="btn log-out">{{ 'Logout'|trans }}</a>
{%- endif -%}
</div>
{% else %}
<div class="alert alert-warning mt-3" role="alert">
{{ 'Your shopping cart is empty' | trans }}
</div>
{% endif %}
</div>
</div>
{% endif %}
<div class="row">
<div class="col-sm-12 text-center pb-4 mb-2">
<strong>{{ 'Need assistance? Call' | trans }}<br><a href="tel:{{ phone_support }}">{{ phone_support }}</a></strong><br/>
<small>({{ 'on workdays' | trans }} 8:00 - 16:30)</small>
</div>
</div>
{{ include(template_from_string(contentBottom)) }}
</div>
</div>
{% endblock %}
{% block dataLayer %}
{% if app.environment == 'prod' %}
<script>
window.dataLayer = window.dataLayer || [];
dataLayer.push({ ecommerce: null });
dataLayer.push({
event: 'view_cart',
ecommerce: {
currency: '{{ currency_ISO }}',
value: '{{ total }}',
items: [ {{ marketingProductsGA4 |raw }} ]
}
});
</script>
{% endif %}
{% endblock %}
{% block title %}{{ 'Shopping cart' | trans }} | {{ parent() }}{% endblock %}
{% block robots %}
{% if
( domainId in [ const('Domain::DOMAIN_ID_RT_SK'), const('Domain::DOMAIN_ID_WS_SK') ] and app.request.locale != 'sk' ) or
( domainId in [ const('Domain::DOMAIN_ID_RT_HU'), const('Domain::DOMAIN_ID_WS_HU') ] and app.request.locale != 'hu' ) or
( domainId in [ const('Domain::DOMAIN_ID_RT_CZ'), const('Domain::DOMAIN_ID_WS_CZ') ] and app.request.locale != 'cz' ) or
( domainId in [ const('Domain::DOMAIN_ID_RT_EU'), const('Domain::DOMAIN_ID_WS_EU') ] and app.request.locale != 'en' )
%}
<meta name="robots" content="noindex, nofollow, noarchive">
{% else %}
<meta name="robots" content="noindex">
{% endif %}
{% endblock %}
{% block bodyClass %}checkout-body-bg{% endblock %}
{% block header %}
{{ include(template_from_string(header)) }}
{% endblock %}
{% block footer %}
{{ include(template_from_string(footer)) }}
{% endblock %}
{% block javascripts %}
{{ parent() }}
<script type="text/javascript" src="{{ asset('theme/owl-carousel/owl.carousel.min.js'|appendAssetCache) }}"></script>
<script type="text/javascript">
var couponCodeCheckUrl = '{{ path("cart_coupon") }}';
function stockItemRemove (basketItemId, productId, stockItemCode) {
$.ajax({
url: '{{ path("product_stock_item_remove") }}',
data: { basketItemId, productId, stockItemCode },
success: function(json) {
if (json.status === 'succes') {
location.reload();
}
}
});
}
if (document.querySelector('.cart-content-top .alert-success')) {
setTimeout(() => {
document.querySelector('.cart-content-top .alert-success').remove();
}, 5000);
}
if (document.getElementById('couponCode')) {
if (document.body.clientWidth > 685) {
document.getElementById('couponCode').classList.add('show');
} else {
document.getElementById('couponCode').classList.remove('show');
}
}
$('.cart-content-line').on('click', '.remove', function() {
removeCartContentLine(this);
});
function removeCartContentLine (element) {
updateButton('loading', element);
$.ajax({
url: '{{ path("cart_remove") }}',
type: 'post',
data: {
item: element.dataset.item,
option: element.dataset.option,
productName: element.dataset.name,
productId: element.dataset.productId
},
dataType: 'json',
beforeSend: function() {
$('.steps-content-box a, .cart-content-back a, .plus, .minus, .remove, .btn-checkout, input').prop('disabled', true);
},
success: function(json) {
if ( parseInt(element.dataset.option) == 0 ) {
gtag('event', 'remove_from_cart', { "items": [{ "id": element.dataset.productId, "name": element.dataset.name }]});
}
setTimeout(function () {
location.reload();
}, 100);
}
});
}
// cart: clear removed array
$.ajax({url: '{{ path("cart_clear_removed_array") }}', type: 'get' });
$('#undo-removed-item').on('click', function(e) {
var removedItem = JSON.parse($('input[name=removedItem]').val());
var attributeOptions = [];
removedItem.attributes.forEach(element => {
attributeOptions.push(element.attribute_option)
});
let postData = {
product_id: removedItem.productId,
option: attributeOptions,
quantity: removedItem.quantity,
stockItems: (removedItem.stockItemCodes ?? false)
}
$.ajax({
url: '{{ path("cart_add") }}',
type: 'post',
data: postData,
dataType: 'json',
success: function(json) {
if ( json['error'] ) {
$('#notification').html(json['error']).modal('show');
}
if ( json['success'] ) {
$.ajax({
url: '{{ path("cart_remove_last_removed") }}',
type: 'post',
data: { product_id: removedItem.productId },
dataType: 'json',
success: function(json) {
if ( json['success'] == false ) {
$('#notification').html(json['error']).modal('show');
return;
}
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 }]});
setTimeout(function () {
location.reload();
}, 100);
}
});
}
}
});
});
$('.cart-content-line .product-quantity').on('click', '.plus', function() {
var self = this;
var quantity = parseInt($('input[data-id="' + $(this).data('id') + '"]').val()) + 1;
$.ajax({
url: '{{ path("cart_update") }}',
type: 'POST',
data: { item: $(self).data('id'), quantity: quantity },
dataType: 'json',
beforeSend: function() {
$('.steps-content-box a, .cart-content-back a, .plus, .minus, .remove, .btn-checkout, input').prop('disabled', true);
$(self).button('loading');
},
success: function(json) {
$(".alert:not('.delivery-price-info'), .text-danger").remove();
if ( json.error){
if (json.error.length > 0) {
$('.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>');
for (i in json.error) {
$('.cart-content-line[data-id="' + json.error[i] + '"] .cart-content-product-name.main').append('<span class="text-danger">***</span>')
}
}
} else if ( json.redirect ) {
location = json.redirect;
return;
} else if ( json.product ) {
$('.cart-content-line[data-id="' + json.product.id + '"] .product-quantity input').val(json.product.quantity);
if ( json.product.originalPrice != '0' ) {
$('.cart-content-line[data-id="' + json.product.id + '"] .cart-content-original-price.main').html(json.product.originalPrice);
$('.cart-content-line[data-id="' + json.product.id + '"] .cart-content-discounted-price.main').html(json.product.price);
} else {
$('.cart-content-line[data-id="' + json.product.id + '"] .cart-content-price.main').html(json.product.price);
}
if ( json.product.options ) {
for ( i in json.product.options ) {
$('.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);
}
}
}
if ( json.subTotal ) {
$('.cart-content-middle .subtotal-price').html(json.subTotal);
}
if ( json.discount ) {
$('.cart-content-middle .code-applied .text-end').html(json.discount);
}
if ( json.total ) {
$('.cart-content-middle .total-price').html(json.total);
}
if ( json.stock ) {
if ( json.stock.length > 0 ) {
$('.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>');
for ( i in json.stock ) {
$('.cart-content-line[data-id="' + json.stock[i] + '"] .cart-content-product-name.main').append('<span class="text-danger">***</span>')
}
}
}
$('.steps-content-box a, .cart-content-back a, .plus, .minus, .remove, .btn-checkout, input').prop('disabled', false);
$(self).button('reset');
}
});
});
$('.cart-content-line .product-quantity').on('click', '.minus', function() {
var self = this;
var quantity = parseInt($('input[data-id="' + $(this).data('id') + '"]').val()) - 1;
if ( quantity < 1 ) {
removeCartContentLine($('.remove-product', $(this).parent().parent().parent().parent())[0]);
return;
}
$.ajax({
url: '{{ path("cart_update") }}',
type: 'POST',
data: { item: $(this).data('id'), quantity: quantity },
dataType: 'json',
beforeSend: function() {
$('.steps-content-box a, .cart-content-back a, .plus, .minus, .remove, .btn-checkout, input').prop('disabled', true);
$(self).button('loading');
},
success: function(json) {
$(".alert:not('.delivery-price-info'), .text-danger").remove();
if ( json.redirect ) {
location = json.redirect;
return;
} else if ( json.product ) {
$('.cart-content-line[data-id="' + json.product.id + '"] .product-quantity input').val(json.product.quantity);
if ( json.product.originalPrice != '0' ) {
$('.cart-content-line[data-id="' + json.product.id + '"] .cart-content-original-price.main').html(json.product.originalPrice);
$('.cart-content-line[data-id="' + json.product.id + '"] .cart-content-discounted-price.main').html(json.product.price);
} else {
$('.cart-content-line[data-id="' + json.product.id + '"] .cart-content-price.main').html(json.product.price);
}
if ( json.product.options ) {
for ( i in json.product.options ) {
$('.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);
}
}
}
if ( json.subTotal ) {
$('.cart-content-middle .subtotal-price').html(json.subTotal);
}
if ( json.discount ) {
$('.cart-content-middle .code-applied .text-end').html(json.discount);
}
if ( json.total ) {
$('.cart-content-middle .total-price').html(json.total);
}
if ( json.stock ) {
if ( json.stock.length > 0 ) {
$('.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>');
for ( i in json.stock ) {
$('.cart-content-line[data-id="' + json.stock[i] + '"] .cart-content-product-name.main').append('<span class="text-danger">***</span>')
}
}
}
$('.steps-content-box a, .cart-content-back a, .plus, .minus, .remove, .btn-checkout, input').prop('disabled', false);
$(self).button('reset');
}
});
});
$('.cart-content-line .product-quantity').on('keyup', 'input', function() {
var self = this;
var quantity = parseInt($(this).val());
if ( quantity < 1 ) {
return;
}
$.ajax({
url: '{{ path("cart_update") }}',
type: 'POST',
data: { item: $(this).data('id'), quantity: quantity },
dataType: 'json',
beforeSend: function() {
$('.steps-content-box a, .cart-content-back a, .plus, .minus, .remove, .btn-checkout, input').prop('disabled', true);
$(self).button('loading');
},
success: function(json) {
$(".alert:not('.delivery-price-info'), .text-danger").remove();
if ( json.redirect ) {
location = json.redirect;
return;
} else if ( json.product ) {
$('.cart-content-line[data-id="' + json.product.id + '"] .product-quantity input').val(json.product.quantity);
if ( json.product.originalPrice > 0 ) {
$('.cart-content-line[data-id="' + json.product.id + '"] .cart-content-original-price.main').html(json.product.originalPrice);
$('.cart-content-line[data-id="' + json.product.id + '"] .cart-content-discounted-price.main').html(json.product.price);
} else {
$('.cart-content-line[data-id="' + json.product.id + '"] .cart-content-price.main').html(json.product.price);
}
if ( json.product.options ) {
for ( i in json.product.options ) {
$('.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);
}
}
}
if ( json.subTotal ) {
$('.cart-content-middle .subtotal-price').html(json.subTotal);
}
if ( json.discount ) {
$('.cart-content-middle .code-applied .text-end').html(json.discount);
}
if ( json.total ) {
$('.cart-content-middle .total-price').html(json.total);
}
if ( json.stock ) {
if ( json.stock.length > 0 ) {
$('.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>');
for ( i in json.stock ) {
$('.cart-content-line[data-id="' + json.stock[i] + '"] .cart-content-product-name.main').append('<span class="text-danger">***</span>')
}
}
}
$('.steps-content-box a, .cart-content-back a, .plus, .minus, .remove, .btn-checkout, input').prop('disabled', false);
$(self).button('reset');
}
});
});
$(document).on('click', '#apply-code-cart', function() {
var self = this;
$.ajax({
url: '{{ path("cart_coupon") }}',
type: 'POST',
data: { coupon: $('#coupon-code').val() },
dataType: 'json',
beforeSend: function() {
$('.steps-content-box a, .cart-content-back a, .plus, .minus, .remove, .btn-checkout, input').prop('disabled', true)
$(self).button('loading')
},
success: function(json) {
$('.error-text').remove();
if ( json.error ) {
$(self).parent().after('<div class="error-text col-12 float-start mt-1"><span>' + json.error + '</span></div>');
document.querySelector('#coupon-code').style.backgroundColor = '#f6e6e7';
document.querySelector('#coupon-code').style.color = '#e25868';
$('.steps-content-box a, .cart-content-back a, .plus, .minus, .remove, .btn-checkout, input').prop('disabled', false);
$(self).button('reset');
return;
}
location.reload();
}
});
});
{% if loginError is defined %}
{% if loginError.signInRequired is defined %}
document.getElementById('log-out-and-log-in-customer').addEventListener('click', () => {
ajax.get(
"{{ path('customer_logout') }}"
);
});
{% else %}
document.getElementById('log-out-customer-and-reload').addEventListener('click', () => {
ajax.get(
"{{ path('customer_logout') }}",
{},
() => {
location.reload();
}
);
});
{% endif %}
{% endif %}
$(document).on('click', '#coupon-remove', function() {
$.ajax({
url: '{{ path("cart_coupon_remove") }}',
type: 'POST',
dataType: 'json',
success: function(json) {
$('.cart-content-line.code-applied').remove()
location.reload();
}
});
});
//--!></script>
{% if expire is defined %}
<script type="text/javascript">
var countDownDate = new Date('{{ expire }}').getTime();
var counter = setInterval(function() {
var now = new Date().getTime();
var distance = countDownDate - now;
var hours = Math.floor(( distance % ( 1000 * 60 * 60 * 24 )) / ( 1000 * 60 * 60 ));
if ( hours < 10 ) {
hours = '0' + hours;
}
var minutes = Math.floor(( distance % ( 1000 * 60 * 60 )) / ( 1000 * 60 ));
if ( minutes < 10 ) {
minutes = '0' + minutes;
}
var seconds = Math.floor(( distance % ( 1000 * 60 )) / 1000 );
if ( seconds < 10 ) {
seconds = '0' + seconds;
}
if ( document.getElementById("basket-expire") !== null ) {
document.getElementById("basket-expire").innerHTML = hours + ':' + minutes + ':' + seconds;
if ( distance < 0 ) {
clearInterval(counter);
document.getElementById("basket-expire").innerHTML = '{{ 'Expired' | trans }}';
}
}
}, 1000);
//--!></script>
{% endif %}
{% endblock %}