{% from 'utils.html.twig' import ico, imgUpload %}
<div id="cart-list--content" class="cart step-container" data-expand="true">
{# PRODUCT LIST #}
<div class="product-list">
{% set showDiscount = (cartSubtotalDiff > 0) %}
{% for cart in carts %}
{% set hasAppliedCoupon = false %}
{% set hasAvaliablePublicCoupons = false %}
{# HAS COUPON #}
{% if isModuleActive('product_coupon_module') %}
{# HAS COUPON APPLIED #}
{% set hasAppliedCoupon = cart.productCoupon is not empty %}
{# HAS COUPONS AVALIABLE #}
{% set hasAvaliablePublicCoupons = cart.productOfferCouponTotal > 0 %}
{% endif %}
<div class="product cart-box">
<div class="content-cart">
<div class="cover">
<div class="mini">
{{
imgUpload(
cart.productOffer.productPage.photo,
enum('AbstractEnum::PATH_PRODUCT_PHOTO'),
'product-photo',
cart.product.title
)
}}
</div>
</div>
<h3 class="title">{{ cart.product.title }}</h3>
{# PRICE #}
{% set infoCycle = installmentPeriodText(cart.productOffer.planCycle) %}
<div class="price">
{# TRIAL #}
{% if cart.productOffer.allowTrial and not userHasProduct(cart.product, true) %}
<p class="trial">{{ cart.productOffer.trialPeriod }} {{ getLanguage('free_days', 'cart') }}</p>
{# NO TRIAL #}
{% else %}
{% set priceOriginal = null %}
{# HAS COUPON APPLIED #}
{% if hasAppliedCoupon %}
{% set priceOriginal = cart.productOffer.priceReal %}
{% endif %}
{# HAS DISPLAY #}
{% if cart.productOffer.priceDisplay > cart.price %}
{% set priceOriginal = cart.productOffer.priceDisplay %}
{% endif %}
{% if priceOriginal is not null %}
<small class="price-original">
{{ getLanguage('of', 'cart') }} <s>{{ cart.productOffer.currencySymbol }} {{ priceOriginal|number_format(2, ',', '.') }}</s> {{ getLanguage('by', 'cart') }}
</small>
{% endif %}
{% set infoParcel = getOfferParcelInfo(cart.productOffer, cart) %}
<p class="price-offer">
{% if infoParcel.maxInstallments > 1 %}
{{ infoParcel.maxInstallments }}x {{ cart.productOffer.currencySymbol }} {{ infoParcel.parcelPrice|number_format(2, ',', '.') }}
{% else %}
{{ cart.productOffer.currencySymbol }} {{ cart.price|number_format(2, ',', '.') }}
{% if cart.productOffer.product.type == enum('ProductEnum::SUBSCRIPTION') or cart.productOffer.allowRecurrency == enum('ProductOfferEnum::YES') %}
/{{ infoCycle.text }}
{% endif %}
{% endif %}
</p>
{% if infoParcel.maxInstallments > 1 %}
<p class="preco-atual">
{{ getLanguage('or', 'cart') }}
<small>
{{ cart.productOffer.currencySymbol }} {{ cart.price|number_format(2, ',', '.') }}
{% if cart.productOffer.product.type == enum('ProductEnum::SUBSCRIPTION') or cart.productOffer.allowRecurrency == enum('ProductOfferEnum::YES') %}
/{{ infoCycle.text }}
{% endif %}
</small>
</p>
{% endif %}
{# MEMBERSHIP FEE #}
{% if cart.membershipFee > 0 %}
{% if cart.productCoupon is not empty
and cart.productCoupon.applyMembershipFee == enum('ProductCouponEnum::YES')
and isModuleActive('product_coupon_module') %}
<del class="price-membership">+ {{ getLanguage('membership_fee_of', 'cart') }} {{ cart.productOffer.currencySymbol }} {{ cart.membershipFee|number_format(2, ',', '.') }}</del>
{% else %}
<p class="price-membership">+ {{ getLanguage('membership_fee_of', 'cart') }} {{ cart.productOffer.currencySymbol }} {{ cart.membershipFee|number_format(2, ',', '.') }}</p>
{% endif %}
{% endif %}
{% endif %}
</div>
{# HAS APPLIED COUPON AND IS SUBSCRIPTION #}
{% set isSubscription = cart.productOffer.product.type == enum('ProductEnum::SUBSCRIPTION')? true : false %}
{% if cart.productCoupon and isSubscription %}
{% set isAllLifetime = (cart.productOffer.planLifetime == 1 and cart.productCoupon.planLifetime == 1)? true:false %}
{% if isAllLifetime == false %}
<div class="coupon modal-coupon-charge js--open-modal-coupons-charge-cart{{ (cart.productCoupon is not empty and hasAvaliablePublicCoupons)? ' status--added' }}"
data-url="{{ path('listCouponChargeByProductOffers', { cartId: cart.id }) }}"
>
{% elseif hasAvaliablePublicCoupons %}
<div class="coupon modal-coupon js--open-modal-coupons-cart{{ (cart.productCoupon is not empty)? ' status--added' }}"
data-url="{{ path('listCouponByProductOffers', { productOfferId: cart.productOffer.id }) }}"
data-coupon-id="{{ (cart.productCoupon.id is defined)? cart.productCoupon.id }}"
data-cart-id="{{ cart.id }}"
>
{# ADDED PRIVATE COUPON #}
{% elseif cart.productCoupon.public == 0 %}
<div class="coupon status--added">
{% endif %}
{% elseif hasAvaliablePublicCoupons %}
<div class="coupon modal-coupon js--open-modal-coupons-cart{{ (cart.productCoupon is not empty)? ' status--added' }}"
data-url="{{ path('listCouponByProductOffers', { productOfferId: cart.productOffer.id }) }}"
data-coupon-id="{{ (cart.productCoupon.id is defined)? cart.productCoupon.id }}"
data-cart-id="{{ cart.id }}">
{# ADDED PRIVATE COUPON #}
{% elseif cart.productCoupon and cart.productCoupon.public == 0 %}
<div class="coupon status--added">
{% else %}
<div class="coupon">
{% endif %}
{# LABEL #}
{% if (hasAvaliablePublicCoupons) or (cart.productCoupon and cart.productCoupon.public == 0) %}
<span class="ico">{{ ico('ticket') }}</span>
<div class="key-coupon">
<small>{{ getLanguage('coupon', 'cart') }}</small>
{# ADDED COUPON #}
{% if cart.productCoupon is not empty %}
<p class="coupon-key">
{{ cart.productCoupon.key }} 
{% if cart.productCoupon.discountType == enum('ProductCouponEnum::CURRENCY') %}
-{{ cart.productOffer.currencySymbol }} {{ cart.productCoupon.discount|number_format(2, ',', '.') }}
{% elseif cart.productCoupon.discountType == enum('ProductCouponEnum::PERCENTAGE') %}
{{ cart.productCoupon.discount|number_format(2, ',', '.') }} % {{ getLanguage('discount', 'cart') }}
{% endif %}
</p>
{# NUMBER OF COUPONS #}
{% elseif hasAvaliablePublicCoupons %}
<p class="coupon-key">
{% set plural = (cart.productOfferCouponTotal == 1) ? 'avaliable' : 'avaliable_plural' %}
{{ cart.productOfferCouponTotal }} {{ getLanguage(plural, 'cart') }}
</p>
{% endif %}
</div>
{% endif %}
</div>{# -/.coupon #}
</div>
{% if isCart %}
<div class="box-actions">
<button
data-route="{{ path('cartDelete', { id: cart.id, isAjaxRequest: true }) }}"
data-id="{{ cart.id }}"
class="js--cart-delete"
data-tooltip-text="{{ getLanguage('delete_item', 'cart') }}"
data-tooltip-class="tooltip-base">
<i class="ico-delete far fa-times-circle"></i>
<i class="loader">{{ ico('loader-wish') }}</i>
</button>
</div>
{% endif %}
</div>
{% endfor %}
</div>
{# DISCOUNT FORM #}
<div class="discount cart-box">
{% if isModuleActive('product_coupon_module') %}
{% if isCart %}
<form class="coupom js--coupom-form" action="{{ path('applyCartCoupon') }}" method="post" novalidate>
<div class="input-wrap">
<label class="ico" for="product-coupom">{{ ico('ticket') }}</label>
<input type="text" name="couponKey" id="product-coupom" placeholder="{{ getLanguage('coupon_code', 'cart') }}" required>
<button type="submit">OK</button>
</div>
</form>
{% else %}
<form class="coupom js--coupom-form refresh" method="get" novalidate>
<div class="input-wrap">
<label class="ico" for="product-coupom">{{ ico('ticket') }}</label>
<input type="text" name="couponKey" id="product-coupom" placeholder="{{ getLanguage('coupon_code', 'cart') }}" required>
<button type="submit">OK</button>
</div>
</form>
{% endif %}
{% if showDiscount %}
<div class="calc" data-show="{{ showDiscount }}">
<p class="subtit">{{ getLanguage('without_discount', 'cart') }}</p>
<p class="value label-discount">
{{ getConfig('currency_symbol') }} <span id="list-full">{{ cartDisplaySubtotal|number_format(2, ',', '.') }}</span>
</p>
</div>
<div class="calc" data-show="{{ showDiscount }}">
<p class="subtit">{{ getLanguage('total_discount', 'cart') }}</p>
<p class="value label-discount">
{{ (cartSubtotalDiff > 0) ? '-' }}{{ getConfig('currency_symbol') }} <span id="list-discount">{{ cartSubtotalDiff|number_format(2, ',', '.') }}</span>
</p>
</div>
{% endif %}
{% endif %}
<div>
<p class="total">
TOTAL {{ getConfig('currency_symbol') }}
<b id="list-total">{{ cartSubtotal|number_format(2, ',', '.') }}</b>
</p>
</div>
</div>
{# ACTIONS #}
<div class="base-actions">
{% if isCart %}
<a href="{{ path('productListCourses', { type: "courses" }) }}">{{ getLanguage('kepp_buying', 'cart') }}</a>
{% endif %}
<button
id="btn-cart-finish"
type="button"
data-initiate="{{ path('cartInitiateCheckout') }}"
data-step="{{ user ? showInfoStep ? '#cart-step-info' : hasContracts ? '#cart-step-contract' : '#cart-step-payment' : '#cart-step-login' }}"
class="btn-confirmar"
>{{ getLanguage('finish', 'cart') }}</button>
</div>
</div>