{% set additionalButtonCaption = additionalButtonCaption is defined and not offerIsFreeForUser ? additionalButtonCaption : '' %}
{% if not pastOffer and offer.getFreeCodesCount() > 0 %}
<a style="display: none" class="button button--primary button--block" id="buyCodeButtonFake"><img src="/images/loading-animation.gif"/> </a>
{% if (offer.getID() == constant('Slivki\\Entity\\Offer::PETROL_OFFER_ID')) %}
<a onclick="if (window.google_tag_manager) {ga('send', 'event', 'Buy code', 'Click', '{{ getURL("Slivki:Default:details", offer.getID()) }}');}ym(20933521,'reachGoal','getcode-click');document.location='/oplata-promokoda-azs'"
class="button button--block {{ isMobileDevice() ? 'mobile'}} by-code-button text-uppercase" id="buyCodeButton">
{% if offerIsFreeForUser %}
БЕСПЛАТНЫЙ ПРОМОКОД {{ additionalButtonCaption|raw }}
{% else %}
{{ buyButtonLabel|raw }} {{ additionalButtonCaption|raw }}
{% endif %}
</a>
{% else %}
{% if (buyCodePopup == '') %}
{% if isMobileDevice() or oldDetails is defined %}
<a onclick="if (window.google_tag_manager) {ga('send', 'event', 'Buy code', 'Click', '{{ getURL("Slivki:Default:details", offer.getID()) }}');} ym(20933521,'reachGoal','getcode-click'); {{ isMobileDevice() ? 'document.location="/oplata/' ~ offer.getID() ~ '"' }};"
class="{{ isMobileDevice() ? 'mobile' : 'old-details'}} d-flex justify-content-center align-items-center text-uppercase button-by-code button" id="buyCodeButton">
{{ buyButtonLabel|raw }} {{ additionalButtonCaption|raw }}
</a>
{% else %}
<a data-toggle="tab" role="tab" href="#offerSelectPromocodeAmount" class="d-flex justify-content-center align-items-center text-uppercase button-by-code button">{{ buyButtonLabel|raw }} {{ additionalButtonCaption|raw }}</a>
{% endif %}
{% else %}
{% if isMobileDevice() %}
<a onclick="if (window.google_tag_manager) {ga('send', 'event', 'Buy code', 'Click', '{{ getURL("Slivki:Default:details", offer.getID()) }}');} ym(20933521,'reachGoal','getcode-click'); document.location='{{ buyCodePopup == '#confirmBox' ? '/oplata-balance/' : '/oplata/'}}{{ offer.getID() }}'"
class="{{ isMobileDevice() ? 'mobile'}} d-flex justify-content-center align-items-center text-uppercase button-by-code button" id="buyCodeButton">
{{ buyButtonLabel|raw }} {{ additionalButtonCaption|raw }}
</a>
{% else %}
{% if offer.isBuyCodeInAppOnly() and app.user() %}
<a class="{{ isMobileDevice() ? 'mobile'}} d-flex justify-content-center align-items-center text-uppercase button-by-code button" data-toggle="modal"
data-target="#byCodesAlwaysApp" id="buyCodeButton">
{{ buyButtonLabel|raw }} {{ additionalButtonCaption|raw }}
</a>
{% elseif not offer.isBuyCodeInAppOnly() and app.user() %}
<a onclick="if (window.google_tag_manager) {ga('send', 'event', 'Buy code', 'Click', '{{ getURL("Slivki:Default:details", offer.getID()) }}');} ym(20933521,'reachGoal','getcode-click');"
class="{{ isMobileDevice() ? 'mobile'}} d-flex justify-content-center align-items-center text-uppercase button-by-code button" data-toggle="modal"
data-target="{{ buyCodePopup }}" id="buyCodeButton">
{{ buyButtonLabel|raw }} {{ additionalButtonCaption|raw }}
</a>
{% elseif not offer.isBuyCodeInAppOnly() and not app.user() or offer.isBuyCodeInAppOnly() and not app.user() %}
<a class="{{ isMobileDevice() ? 'mobile'}} d-flex justify-content-center align-items-center text-uppercase button-by-code button" data-toggle="modal" data-target=".modal-auth" id="buyCodeButton">
{{ buyButtonLabel|raw }} {{ additionalButtonCaption|raw }}
</a>
{% endif %}
{% endif %}
{% endif %}
{% endif %}
{% endif %}