Created
July 15, 2019 18:05
-
-
Save NandoKstroNet/ea5d0c6f1a69f0acc0ecd541ea24ed3c to your computer and use it in GitHub Desktop.
código da tela de carrinho - Projeto Loja Formação PHP - formacaophp.com.br
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php require TEMPLATES . '/includes/header.phtml';?> | |
<div class="row"> | |
<div class="col-12"> | |
<?php require TEMPLATES . '/includes/message.phtml';?> | |
</div> | |
</div> | |
<div class="row"> | |
<div class="col-12"> | |
<h2>Carrinho</h2> | |
<hr> | |
</div> | |
</div> | |
<div class="row"> | |
<?php if(!is_null($cart)): ?> | |
<div class="col-12"> | |
<table class="table"> | |
<thead> | |
<tr> | |
<th>Produto</th> | |
<th>Preço</th> | |
<th>Quantidade</th> | |
<th>Subtotal</th> | |
<th></th> | |
</tr> | |
</thead> | |
<tbody> | |
<?php | |
$total = 0; | |
foreach($cart as $c): ?> | |
<tr> | |
<td><?=$c['name'];?></td> | |
<td>R$ <?=number_format($c['price'], 2,',', '.');?></td> | |
<td> | |
<?=$c['qtd'];?> | |
</td> | |
<td> | |
<?php $subtotal = $c['qtd'] * $c['price'];?> | |
R$ <?=number_format($subtotal, 2,',', '.');?> | |
</td> | |
<td> | |
<a href="<?=HOME;?>/cart/remove/<?=$c['slug'];?>" class="btn btn-danger"> | |
<i class="fa fa-trash"></i> | |
</a> | |
</td> | |
</tr> | |
<?php | |
$total += $subtotal; | |
endforeach; | |
?> | |
<tr> | |
<td></td> | |
<td></td> | |
<td></td> | |
<td class="text-left">Total: R$ <?=number_format($total, 2,',', '.');?></td> | |
<td></td> | |
</tr> | |
</tbody> | |
</table> | |
</div> | |
<div class="col-12"> | |
<a href="<?=HOME;?>/cart/cancel" class="btn-lg btn btn-danger">Cancelar Compra</a> | |
<a href="<?=HOME;?>/cart/checkout" class="btn-lg btn btn-success float-right">Finalizar Compra</a> | |
</div> | |
<?php else: ?> | |
<div class="col-12"> | |
<div class="alert alert-warning"> | |
Carrinho vazio... | |
</div> | |
</div> | |
<?php endif;?> | |
</div> | |
<?php require TEMPLATES . '/includes/footer.phtml';?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment