<?php if ($error_warning) { ?>
<div class="alert alert-warning"><i class="fa fa-exclamation-circle"></i> <?php echo $error_warning; ?></div>
<?php } ?>
<?php if ($shipping_methods) { ?>
<p><?php echo $text_shipping_method; ?></p>

<?php foreach ($shipping_methods as $shipping_method) { ?>
<?php if (!$shipping_method['error']) { ?>
<?php foreach ($shipping_method['quote'] as $quote) { ?>
    <?php
        if ($quote['code'] == 'yourdelivery') {
            $code_id = $quote['code'];
        } elseif ($quote['code'] == 'yourv') {
            $code_id = $quote['code'];
        } else {
            $code_id = '';
        }
    ?>
    <div class="radio" id="<?=$code_id?>">
        <label>
          <?php if ($quote['code'] == $code || !$code) { ?>
            <?php $code = $quote['code']; ?>
            <input type="radio" name="shipping_method" value="<?php echo $quote['code']; ?>" checked="checked" />
          <?php } else { ?>
            <input type="radio" name="shipping_method" value="<?php echo $quote['code']; ?>" />
          <?php } ?>
          <?php echo $quote['title']; ?> - <?php echo $quote['text']; ?>
        </label>
    </div>
<?php } ?>
<?php } else { ?>
<div class="alert alert-danger"><?php echo $shipping_method['error']; ?></div>
<?php } ?>
<?php } ?>
<?php } ?>

<input type="text" name="yourv" class="form-control level-up-form-control" value="<?=$yourv?>" />


<p><strong><?php echo $text_comments; ?></strong></p>
<textarea name="comment" rows="8" class="form-control"><?php echo $comment; ?></textarea>
<div class="buttons">
  <div class="pull-right">
    <input type="button" value="<?php echo $button_continue; ?>" id="button-shipping-method" data-loading-text="<?php echo $text_loading; ?>" class="btn btn-primary" />
  </div>
</div>
<script type="text/javascript">
    var CoShMethod = $('#collapse-shipping-method');

    // =====step 2=====
    $(function(){
        CoShMethod.find('div.radio:nth-of-type(n+5)').wrapAll("<div class='new_radio_group_for_toggle'></div>");
        var RGroup = $(".new_radio_group_for_toggle");

        RGroup.hide();
        $("#yourdelivery label").on('click', function(){
            $(".new_radio_group_for_toggle").show(400);
        });
        CoShMethod.find('.panel-body > div.radio').not("#yourdelivery").find('label').on('click', function(){
            RGroup.hide(400);
            RGroup.find('input[type=radio]').removeAttr('checked');
        });
        RGroup.find('input[type=radio]').attr("name", "shipping_method_child");
    });

    // =====step 3=====
    $(function(){
        var yourv = $(".form-control.level-up-form-control");

        yourv.hide();
        $("#yourv label").on('click', function(){
            yourv.show(400);
        });
        CoShMethod.find('div.radio').not("#yourv").find('label').on('click', function(){
            yourv.hide(400).val('');
        });
    });
</script>