<?php $__env->startSection('title', 'Checkout'); ?>

<?php $__env->startSection('content'); ?>
    <article id="checkout">
        <div class="breadcrumb">
            <div class="container d-flex align-items-center">
                <a href="<?php echo e(url('/')); ?>">Inicio</a>
                <span><?php echo $__env->yieldContent('title'); ?></span>
            </div>
        </div>
        <section>
            <div class="container">
                <?php echo Form::open(); ?>

                <div class="row row-grid">
                    <div class="col-md-6 mb-3">
                        <h2>Datos de facturación</h2>
                        <div class="form-group">
                            <?php echo Form::label('first_name', 'Nombre *', ['class' => 'form-label']); ?>

                            <?php echo Form::text('first_name', auth()->user()->user_data->first_name, ['required', 'class' => 'form-control']); ?>

                        </div>
                        <div class="form-group">
                            <?php echo Form::label('last_name', 'Apellido *', ['class' => 'form-label']); ?>

                            <?php echo Form::text('last_name', auth()->user()->user_data->last_name, ['required', 'class' => 'form-control']); ?>

                        </div>
                        <div class="form-group">
                            <?php echo Form::label('business_name', 'Razón social (opcional)', ['class' => 'form-label']); ?>

                            <?php echo Form::text('business_name', null, ['class' => 'form-control']); ?>

                        </div>
                        <div class="form-group">
                            <?php echo Form::label('address', 'Dirección *', ['class' => 'form-label']); ?>

                            <?php echo Form::textarea('address', null, ['class' => 'form-control', 'required', 'placeholder' => 'Calle y número de casa. Departamento, piso, etc. (opcional)', 'rows' => 3]); ?>

                        </div>
                        <div class="form-group">
                            <?php echo Form::label('city', 'Ciudad *', ['class' => 'form-label']); ?>

                            <?php echo Form::text('city', null, ['class' => 'form-control', 'required']); ?>

                        </div>
                        <div class="form-group">
                            <?php echo Form::label('phone', 'Teléfono *', ['class' => 'form-label']); ?>

                            <?php echo Form::text('phone', auth()->user()->user_data->phone, ['class' => 'form-control', 'required']); ?>

                        </div>
                        <div class="form-group">
                            <?php echo Form::label('email', 'Email *', ['class' => 'form-label']); ?>

                            <?php echo Form::email('email', auth()->user()->email, ['class' => 'form-control', 'required']); ?>

                        </div>
                    </div>
                    <div class="col-md-6 mb-3">
                        <h2>Datos de envío</h2>
                        <div class="form-group">
                            <ul class="list-unstyled accordion">
                                <?php $__currentLoopData = $shipping_methods; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $shipping_method): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                    <li>
                                        <?php echo Form::radio('shipping_method_id', $shipping_method->id, false, ['id' => 'shippingMethod'.$shipping_method->id, 'class' => 'shipping_method', 'data-price' => $shipping_method->price, 'data-formatted-price' => $shipping_method->price ? num_format($shipping_method->price) : 'Gratis', 'required' => $loop->first]); ?>

                                        <label for="shippingMethod<?php echo e($shipping_method->id); ?>">
                                            <h3><?php echo e($shipping_method->title); ?></h3>
                                            <p><?php echo e($shipping_method->excerpt); ?></p>
                                        </label>
                                    </li>
                                <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                            </ul>
                        </div>
                        <div class="form-group">
                            <input type="checkbox" name="toggleShipping" id="toggleShipping">
                            <label for="toggleShipping">Enviar a otra dirección</label>
                        </div>
                        <div class="form-group d-none">
                            <?php echo Form::label('shipping_data[first_name]', 'Nombre *', ['class' => 'form-label']); ?>

                            <?php echo Form::text('shipping_data[first_name]', auth()->user()->user_data->first_name, ['required', 'class' => 'form-control optional', 'disabled']); ?>

                        </div>
                        <div class="form-group d-none">
                            <?php echo Form::label('shipping_data[last_name]', 'Apellido *', ['class' => 'form-label']); ?>

                            <?php echo Form::text('shipping_data[last_name]', auth()->user()->user_data->last_name, ['required', 'class' => 'form-control optional', 'disabled']); ?>

                        </div>
                        <div class="form-group d-none">
                            <?php echo Form::label('shipping_data[address]', 'Dirección *', ['class' => 'form-label']); ?>

                            <?php echo Form::textarea('shipping_data[address]', null, ['class' => 'form-control optional', 'required', 'placeholder' => 'Calle y número de casa. Departamento, piso, etc. (opcional)', 'rows' => 3, 'disabled']); ?>

                        </div>
                        <div class="form-group d-none">
                            <?php echo Form::label('shipping_data[city]', 'Ciudad *', ['class' => 'form-label']); ?>

                            <?php echo Form::text('shipping_data[city]', null, ['class' => 'form-control optional', 'required', 'disabled']); ?>

                        </div>
                        <div class="form-group">
                            <?php echo Form::label('feedback', 'Observaciones (opcional)', ['class' => 'form-label']); ?>

                            <?php echo Form::textarea('feedback', null, ['class' => 'form-control', 'placeholder' => 'Notas acerca del pedido, instrucciones para envío, etc.', 'rows' => 3]); ?>

                        </div>
                    </div>
                    <div class="col-md-6 mb-3">
                        <h2>Forma de pago</h2>
                        <div class="form-group">
                            <ul class="list-unstyled accordion">
                                <?php $__currentLoopData = $payment_methods; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $payment_method): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                    <li>
                                        <?php echo Form::radio('payment_method_id', $payment_method->id, $loop->first, ['id' => 'paymentMethod'.$payment_method->id]); ?>

                                        <label for="paymentMethod<?php echo e($payment_method->id); ?>">
                                            <h3><?php echo e($payment_method->title); ?></h3>
                                            <p><?php echo e($payment_method->excerpt); ?></p>
                                        </label>
                                    </li>
                                <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                            </ul>
                        </div>
                        <div class="form-group">
                            <ul class="list-unstyled accordion">
                                <li>
                                    <span>Producto</span>
                                    <span>Subtotal</span>
                                </li>
                                <?php $__currentLoopData = Cart::content(); $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $item): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                    <li>
                                        <span><?php echo e($item->name); ?> <b>x<?php echo e($item->qty); ?></b></span>
                                        <h3><b><?php echo e(num_format($item->qty * $item->price)); ?></b></h3>
                                    </li>
                                <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                                <li>
                                    <span>Envío</span>
                                    <h3><b id="shipping">-</b></h3>
                                </li>
                                <li>
                                    <span>Total</span>
                                    <h3><b id="total" data-value="<?php echo e(Cart::subtotal(0, '', '')); ?>"><?php echo e(Cart::subtotal(0, ',', '.')); ?></b></h3>
                                </li>
                            </ul>
                        </div>
                        <div class="btn-container mt-5 text-right">
                            <button type="submit" class="btn">
                                <span>Hacer pedido</span>
                                <i class="far fa-arrow-right"></i>
                            </button>
                        </div>
                    </div>
                    <div class="col-md-6 mb-3">
                        <?php if($options->checkout_image): ?>
                            <img src="<?php echo e(asset($options->checkout_image)); ?>" alt="" class="sticky-image">
                        <?php endif; ?>
                    </div>
                </div>
                <?php echo Form::close(); ?>

            </div>
        </section>
    </article>
<?php $__env->stopSection(); ?>

<?php $__env->startPush('scripts'); ?>
    <script>
        $(function() {
          $('#toggleShipping').on('change', function() {
            if($(this).is(':checked')) {
              $('.optional').removeAttr('disabled');
              $('.optional').parents('.form-group').removeClass('d-none');
            } else {
              $('.optional').attr('disabled', 'disabled');
              $('.optional').parents('.form-group').addClass('d-none');
            }
          });

          $('.shipping_method').on('change', function() {
            $('#shipping').text($(this).data('formatted-price'));
            $('#total').text((parseInt($('#total').data('value')) + parseInt($(this).data('price'))).toLocaleString('es-ES', {
              maximumFractionDigits: 0
            }));
          });
        });
    </script>
<?php $__env->stopPush(); ?>
<?php echo $__env->make('layouts.frontend', \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?><?php /**PATH /home/poshcom/bgreen.posh.com.py/resources/views/templates/checkout.blade.php ENDPATH**/ ?>