{block name='checkout-step3-shipping-options'}
    {$lazyLoadImages=$lazyLoadImages|default:true}
    {et_isShopVersionAtLeast value="5.7.0-rc.3" assign='shopIsAtLeast57'}
    {block name='checkout-step3-shipping-options-heading'}
        <h1>{lang section='account data' key='shippingAndPaymentOptions'}</h1>
    {/block}
    <div class="row">
        <div class="{block name='checkout-step3-shipping-options-content-class'}col col-12 col-lg-9{/block}">
            {block name='checkout-step3-shipping-options-content'}
                {if !isset($Versandarten)}
                    {block name='checkout-step3-shipping-options-alert'}
                        <div role="alert" class="alert alert-danger">{lang key='noShippingMethodsAvailable' section='checkout'}</div>
                    {/block}
                {else}
                    {block name='checkout-step3-shipping-options-form'}
                        <form method="post" action="{get_static_route id='bestellvorgang.php'}" class="form checkout-shipping-form jtl-validate">
                            {csrf_token}

                            {block name='checkout-step3-shipping-options-shipping-payment-wrapper'}
                                <div class="{block name='checkout-step3-shipping-options-shipping-payment-class'}et-boxed-content{/block}">
                                    {block name='checkout-step3-shipping-options-fieldset-shipping-payment'}
                                        <fieldset id="checkout-shipping-payment">
                                            {block name='checkout-step3-shipping-options-legend-shipping-options'}
                                                <div class="h3">{lang key='shippingOptions'}</div>
                                            {/block}
                                            {block name='checkout-step3-shipping-options-shipping-address-link'}
                                                <div class="checkout-shipping-form-change">
                                                    {lang key='shippingTo' section='checkout'}: <span translate="no">{$Lieferadresse->cStrasse} {$Lieferadresse->cHausnummer}, {$Lieferadresse->cPLZ} {$Lieferadresse->cOrt}, {$Lieferadresse->cLand}</span>
                                                    <a href="{get_static_route id='bestellvorgang.php'}?editLieferadresse=1"
                                                        class="btn btn-link btn-sm font-size-sm"
                                                    >
                                                        <span class="text-decoration-underline">{lang key='change'}</span>
                                                        <span class="checkout-shipping-form-change-icon {et_getIcon key="edit"}"></span>
                                                    </a>
                                                </div>
                                            {/block}
                                            {block name='checkout-step3-shipping-options-shipping-address-hr'}
                                                {* <hr> *}
                                            {/block}
                                            {block name='checkout-step3-shipping-options-shipping-options'}
                                                <div class="checkout-shipping-form-options form-group">
                                                    <div class="radio-w-100" id="{uniqid()}" role="group">
                                                        {foreach $Versandarten as $versandart}
                                                            {block name='checkout-step3-shipping-options-shipment'}
                                                                <div class="custom-control custom-radio">
                                                                    <input
                                                                        class="custom-control-input checkout-shipping-form-options-radio"
                                                                        type="radio"
                                                                        id="del{$versandart->kVersandart}"
                                                                        name="Versandart"
                                                                        value="{$versandart->kVersandart}"
                                                                        {if ($versandart@first)}required{/if}
                                                                        {if (isset($Versandarten) && count($Versandarten) == 1 || $AktiveVersandart == $versandart->kVersandart)}checked{/if}
                                                                    >
                                                                    <label for="del{$versandart->kVersandart}" class="custom-control-label">
                                                                        <div class="form-row content">
                                                                            {block name='checkout-step3-shipping-options-shipping-option-title'}
                                                                                <div class="col col-9 title">
                                                                                    {block name='checkout-step3-shipping-options-shipping-option-title-image'}
                                                                                        {if $versandart->cBild}
                                                                                            {image fluid=true class="w-20" lazy=$lazyLoadImages src=$versandart->cBild alt=$versandart->angezeigterName|trans}
                                                                                        {/if}
                                                                                    {/block}
                                                                                    {block name='checkout-step3-shipping-options-shipping-option-title-title'}
                                                                                        {if $versandart->angezeigterName|trans === '' && $versandart->cBild === ''}
                                                                                            {$versandart->cName}
                                                                                        {else}
                                                                                            {$versandart->angezeigterName|trans}
                                                                                        {/if}
                                                                                        {if !empty($versandart->angezeigterHinweistext|trans)}
                                                                                            <div>
                                                                                                {$versandart->angezeigterHinweistext|trans}
                                                                                            </div>
                                                                                        {/if}
                                                                                    {/block}
                                                                                    {block name='checkout-step3-shipping-options-shipping-option-info'}
                                                                                        {if !empty($versandart->cLieferdauer|trans)}
                                                                                            <span class="desc">{lang key="shippingTime" section="global"} {$versandart->cLieferdauer|trans}</span>
                                                                                        {/if}
                                                                                    {/block}
                                                                                </div>
                                                                                {/block}

                                                                            {block name='checkout-step3-shipping-options-shipping-option-price'}
                                                                                <div class="col col-3 shipping-option-price price-col">
                                                                                    {$versandart->cPreisLocalized}
                                                                                    {if !empty($versandart->Zuschlag->fZuschlag)}
                                                                                        <div>
                                                                                            <small>
                                                                                                {* Note: This is the only translatable value that is translated by ID - this might be a core bug *}
                                                                                                ({$versandart->Zuschlag->angezeigterName|transById} +{$versandart->Zuschlag->cPreisLocalized})
                                                                                            </small>
                                                                                        </div>
                                                                                    {/if}
                                                                                </div>
                                                                            {/block}
                                                                        </div>
                                                                        <span class="checkout-shipping-form-options-specific-cost">
                                                                            {if isset($versandart->specificShippingcosts_arr)}
                                                                                {foreach $versandart->specificShippingcosts_arr as $specificShippingcosts}
                                                                                    {block name='checkout-step3-shipping-options-shipping-option-cost'}
                                                                                        <div class="row">
                                                                                            <div class="col col-8">
                                                                                                <ul>
                                                                                                    <li>
                                                                                                        <small>{$specificShippingcosts->cName|trans}</small>
                                                                                                    </li>
                                                                                                </ul>
                                                                                            </div>
                                                                                            <div class="col col-4">
                                                                                                <small>
                                                                                                    {$specificShippingcosts->cPreisLocalized}
                                                                                                </small>
                                                                                            </div>
                                                                                        </div>
                                                                                    {/block}
                                                                                {/foreach}
                                                                            {/if}
                                                                        </span>
                                                                    </label>
                                                                </div>
                                                            {/block}
                                                        {/foreach}
                                                    </div>
                                                </div>
                                            {/block}
                                        </fieldset>
                                    {/block}
                                </div>
                            {/block}

                            {* Additional Packaging Types (Zustatzverpackung) *}
                            {if isset($Verpackungsarten) && count($Verpackungsarten) > 0}
                                {block name='checkout-step3-shipping-options-packaging-types-wrapper'}
                                    <div class="et-boxed-content">
                                        {block name='checkout-step3-shipping-options-fieldset-packaging-types'}
                                            <fieldset id="fieldset-packaging-types">
                                                {block name='checkout-step3-shipping-options-legend-packaging-types-hr'}
                                                    {* <hr> *}
                                                {/block}

                                                {block name='checkout-step3-shipping-options-legend-packaging-types'}
                                                    <div class="h3">{lang section='checkout' key='additionalPackaging'}</div>
                                                {/block}
                                                <div id="{uniqid()}" role="group">
                                                {foreach $Verpackungsarten as $oVerpackung}
                                                    {block name='checkout-step3-shipping-options-packaging'}
                                                        <div class="checkout-shipping-form-packaging">
                                                            <div class="custom-control custom-checkbox">
                                                                <input class="custom-control-input"
                                                                    type="checkbox" id="pac{$oVerpackung->kVerpackung}"
                                                                    name="kVerpackung[]"
                                                                    value="{$oVerpackung->kVerpackung}"
                                                                    {if isset($oVerpackung->bWarenkorbAktiv) && $oVerpackung->bWarenkorbAktiv === true || (isset($AktiveVerpackung[$oVerpackung->kVerpackung]) && $AktiveVerpackung[$oVerpackung->kVerpackung] === 1)}checked{/if}
                                                                >
                                                                <label for="pac{$oVerpackung->kVerpackung}" class="custom-control-label">
                                                                    <span class="checkout-shipping-form-packaging-title">
                                                                        {$oVerpackung->cName}
                                                                    </span>
                                                                    <span class="checkout-shipping-form-packaging-cost price-col">
                                                                        {if $oVerpackung->nKostenfrei == 1}
                                                                            {lang key='ExemptFromCharges'}
                                                                        {elseif $shopIsAtLeast57 && JTL\Session\Frontend::getCustomerGroup()->isMerchant()}
                                                                            {$oVerpackung->fNettoLocalized}
                                                                        {else}
                                                                            {$oVerpackung->fBruttoLocalized}
                                                                        {/if}
                                                                    </span>
                                                                    <span class="checkout-shipping-form-packaging-desc">
                                                                        {$oVerpackung->cBeschreibung}
                                                                    </span>
                                                                </label>
                                                            </div>
                                                        </div>
                                                    {/block}
                                                {/foreach}
                                                </div>
                                            </fieldset>
                                        {/block}
                                    </div>
                                {/block}
                            {/if}

                            {block name='checkout-step3-shipping-options-payment-wrapper'}
                                <div class="{block name='checkout-step3-shipping-options-fieldset-payment-class'}et-boxed-content{/block}">
                                    {block name='checkout-step3-shipping-options-fieldset-payment'}
                                        <fieldset id="fieldset-payment">
                                            {block name='checkout-step3-shipping-options-legend-payment-hr'}
                                                    {* <hr> *}
                                            {/block}

                                            {block name='checkout-step3-shipping-options-legend-payment'}
                                                <div class="h3">{lang key='paymentOptions'}</div>
                                            {/block}
                                            {$step4_payment_content}
                                        </fieldset>
                                    {/block}
                                </div>
                            {/block}

                            {if isset($Versandarten)}
                                {block name='checkout-step3-shipping-options-shipping-type-submit'}
                                    <input type="hidden" name="versandartwahl" value="1" />
                                    <input type="hidden" name="zahlungsartwahl" value="1" />

                                    <div class="row checkout-button-row d-none">
                                        <div class="col col-12 col-md-5 ml-auto-util order-1 order-md-2">
                                            {include file="widgets/base/button.tpl" type="submit" classes="btn-block submit_once d-none button-row-mb" variant="primary" label="{lang key='continueOrder' section='account data'}"}
                                        </div>
                                        <div class="col col-12 col-md-4 order-2 order-md-1">
                                            {include file="widgets/base/button.tpl" href="{get_static_route id='bestellvorgang.php'}?editRechnungsadresse=1" variant="secondary" classes="btn-block" title="{lang key='back'}" label="{lang key='back'}"}
                                        </div>
                                    </div>
                                {/block}
                            {/if}
                        </form>
                    {/block}
                {/if}
            {/block}
        </div>

        {* Sidebar *}
        {block name='checkout-step3-shipping-options-sidebar'}
            <div class="col col-12 col-lg-3 ml-auto">
                {include file="widgets/snippets/checkout_sidebar.tpl" context="checkout_step3"}
            </div>
        {/block}
    </div>
    {if isset($smarty.get.editZahlungsart)}
        {block name='checkout-step3-shipping-options-script-scroll'}
            {inline_script}<script>
                $(document).ready(function () {
                    $.evo.extended().smoothScrollToAnchor('#fieldset-payment');
                });
            </script>{/inline_script}
        {/block}
    {/if}
{/block}
