<?php $__env->startSection('title'); ?> <?php echo trans('website.labels.shopping-cart'); ?> - <?php echo Config::get('website.title'); ?> <?php $__env->stopSection(); ?> <?php $__env->startSection('container'); ?> <div class="row"> <div class="col-xs-12 cart"> <h1><?php echo trans('website.labels.shopping-cart'); ?></h1> <ul class="steps clearfix"> <li class="col-xs-3 first active"> <a>1. <?php echo trans('website.labels.shopping-cart'); ?></a> <i class="glyphicon glyphicon-triangle-right"></i> </li> <li class="col-xs-3"> <a>2. <?php echo trans('website.labels.payment-and-shipment'); ?></a> <i class="glyphicon glyphicon-triangle-right"></i> </li> <li class="col-xs-3"> <a>3. <?php echo trans('website.labels.billing-information'); ?></a> <i class="glyphicon glyphicon-triangle-right"></i> </li> <li class="col-xs-3 last"> <a>4. <?php echo trans('website.labels.order-confirmation'); ?></a> </li> </ul> <?php if($errors->cart->count()): ?> <?php foreach($errors->cart->all() as $error): ?> <?php echo Alert::warning($error)->close(); ?> <?php endforeach; ?> <?php endif; ?> <?php echo Form::open(['route' => 'cart.store', 'secure' => true]); ?> <hr size="6" class="line"> <table class="table items"> <thead> <tr> <th class="col-xs-2 text-center"><?php echo trans('website.labels.helios'); ?></th> <th class="col-xs-4"><?php echo trans('website.labels.product'); ?></th> <th class="text-center"><?php echo trans('website.labels.quantity'); ?></th> <th class="text-center"><?php echo trans('website.labels.tax-rate'); ?></th> <th class="text-right"><?php echo trans('website.labels.item-price'); ?></th> <th class="text-right"><?php echo trans('website.labels.price'); ?></th> </tr> </thead> <tbody> <?php $__empty_1 = true; foreach($cart as $row): $__empty_1 = false; ?> <tr class="item"> <td class="col-xs-2 text-center"><?php echo $row->book->helios; ?></td> <td class="col-xs-4"> <a href="<?php echo route('book', [$row->book->route]); ?>" title="<?php echo $row->book->title; ?>"> <?php echo HTML::image($row->book->image->url('small'), $row->book->title, ['class' => 'img-thumbnail']); ?> </a> <a href="<?php echo route('book', [$row->book->route]); ?>"> <h3><?php echo str_limit($row->book->title, 60); ?></h3> </a> <br> <h4><?php echo str_limit($row->book->author, 55); ?></h4> </td> <td class="text-center"> <div class="quantity"> <?php echo Form::text('quantity[' . $row->rowid . ']', $row->qty); ?> <?php echo Form::hidden('rowid', $row->rowid); ?> <div class="btn-group-vertical controls"> <?php echo Button::normal()->extraSmall()->prependIcon(Icon::plus())->withAttributes(['class' => 'plus']); ?> <?php echo Button::normal()->extraSmall()->prependIcon(Icon::minus())->withAttributes(['class' => 'minus']); ?> </div> </div> <?php echo Button::cart()->small()->prependIcon(Icon::trash())->asLinkTo(route('cart.remove', [$row->rowid])); ?> </td> <td class="text-center"><?php echo $row->options->vat; ?>%</td> <td class="text-right"><?php echo number_format($row->price, 2, ',', ' '); ?> &euro;</td> <td class="text-right"><strong class="price"><?php echo number_format($row->subtotal, 2, ',', ' '); ?> &euro;</strong></td> </tr> <?php endforeach; if ($__empty_1): ?> <tr> <td colspan="6" class="empty"> <div class="well well-lg text-center"> <?php echo trans('website.messages.empty-cart'); ?> </div> </td> </tr> <?php endif; ?> </tbody> </table> <div class="row"> <div class="col-xs-6 back"> <i class="glyphicon glyphicon-chevron-left"></i> <?php echo HTML::link(Session::get('url.remember', route('home')), trans('website.labels.continue-shopping')); ?> </div> <?php if(Cart::count()): ?> <div class="col-xs-6"> <div class="well pull-right total"> <div class="clearfix"> <span class="pull-left"><?php echo trans('website.labels.total-with-vat'); ?></span> <strong class="pull-right"><span class="price"><?php echo number_format(Cart::total(), 2, ',', ' '); ?> &euro;</span></strong> </div> <?php echo Button::accept(trans('website.buttons.proceed-to-checkout'))->appendIcon(Icon::triangle_right())->block()->submit()->withAttributes(['class' => 'top-margin']); ?> </div> </div> <?php endif; ?> </div> <?php echo Form::close(); ?> </div> </div> <?php $__env->stopSection(); ?> <?php $__env->startSection('scripts'); ?> @parent function number_format(number, decimals, decPoint, thousandsSep) { decimals = decimals || 0; number = parseFloat(number); if(!decPoint || !thousandsSep) { decPoint = '.'; thousandsSep = ','; } var roundedNumber = Math.round( Math.abs( number ) * ('1e' + decimals) ) + ''; var numbersString = decimals ? roundedNumber.slice(0, decimals * -1) : roundedNumber; var decimalsString = decimals ? roundedNumber.slice(decimals * -1) : ''; var formattedNumber = ""; while(numbersString.length > 3) { formattedNumber += thousandsSep + numbersString.slice(-3); numbersString = numbersString.slice(0,-3); } return (number < 0 ? '-' : '') + numbersString + formattedNumber + (decimalsString ? (decPoint + decimalsString) : ''); } function updateQuantity($item, value) { var prices = <?php echo json_encode(array_map(function($row) { return floatval($row['price']); }, $cart->toArray())); ?>; var $quantity = $item.find('input[name^=quantity]'); var quantity = (parseInt($quantity.val())!=NaN) ? parseInt($quantity.val()) : 1; var rowid = $item.find('input[name=rowid]').val(); var $price = $item.find('.price'); if (quantity<=1 && value==-1) $quantity.val(1); else $quantity.val(quantity + value); $price.html(number_format($quantity.val() * prices[rowid], 2, ',', ' ') + ' &euro;'); } function updateTotal() { var prices = <?php echo json_encode(array_map(function($row) { return floatval($row['price']); }, $cart->toArray())); ?>; var $total = $('.total .price'); var total = 0; $('input[name^=quantity]').each(function(index) { var quantity = (parseInt($(this).val())!=NaN) ? parseInt($(this).val()) : 1; var rowid = $(this).siblings('input[name=rowid]').val(); total += quantity * prices[rowid]; }); $total.html(number_format(total, 2, ',', ' ') + ' &euro;'); } $('.quantity .plus').on('click', function(event) { var $item = $(this).parents('.item'); updateQuantity($item, 1); updateTotal(); }); $('.quantity .minus').on('click', function(event) { var $item = $(this).parents('.item'); updateQuantity($item, -1); updateTotal(); }); $('input[name^=quantity]').on('change', function(event) { var $item = $(this).parents('.item'); var value = parseInt($(this).val()); if (value==NaN || value<=0) { $(this).val(1); } updateQuantity($item, 0); updateTotal(); }); <?php $__env->stopSection(); ?>