-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtienda.php
109 lines (100 loc) · 4.05 KB
/
tienda.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
<?php
require_once('control/funciones.php');
$conexion = conexion();
if (!$conexion) { // Si no hay conexion a la base de datos, mandamos a la pagina de error
header('Location: error.php');
}
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
$para_carrito = array(
'id_producto' => $_POST['id_producto'],
'nombre_producto' => $_POST['nombre_producto'],
'image_producto' => $_POST['image_producto'],
'cantidad_producto' => $_POST['cantidad'],
'precio_producto' => $_POST['precio_producto']
);
$siguiente = count($carrito) + 1;
setcookie("carrito[$siguiente]", json_encode($para_carrito));
header('Location: tienda.php');
}
require_once('control/traer_categorias.php');
if (!isset($_GET['categoria'])) {
$sentencia = $conexion->prepare("SELECT * FROM productos
INNER JOIN categorias ON productos.id_categoria = categorias.id_categoria
ORDER BY id_producto DESC
");
} else {
$filtro = $_GET['categoria'];
$sentencia = $conexion->prepare("SELECT * FROM productos
INNER JOIN categorias ON productos.id_categoria = categorias.id_categoria
WHERE categorias.nombre_categoria = '$filtro'
ORDER BY id_producto DESC
");
}
$sentencia->execute();
$productos = $sentencia->fetchAll();
?>
<!DOCTYPE html>
<html lang="es">
<head>
<?php require_once('vistas/head.php'); ?>
<title>Dahlia - Clothes by Michelle | Tienda</title>
</head>
<body>
<?php require_once('vistas/siderbar.php'); ?>
<div id="wrapper">
<?php require_once('vistas/header.php'); ?>
<section class="shop_grid_area section_padding_100">
<div class="container">
<div class="row">
<div class="col-12 col-md-4 col-lg-3">
<div class="shop_sidebar_area">
<div class="widget catagory mb-50">
<div class="nav-side-menu">
<h6 class="mb-0">Categorías</h6>
<div class="menu-list">
<ul id="menu-content2" class="menu-content collapse out">
<li><a href="?">Ver todo</a></li>
<?php foreach($categorias as $categoria): ?>
<li><a href="?categoria=<?php echo($categoria['nombre_categoria']); ?>"><?php echo($categoria['nombre_categoria']); ?></a></li>
<?php endforeach; ?>
</ul>
</div>
</div>
</div>
</div>
</div>
<div class="col-12 col-md-8 col-lg-9">
<div class="shop_grid_product_area">
<div class="row">
<?php foreach($productos as $producto): ?>
<div
class="col-12 col-sm-6 col-lg-4 single_gallery_item wow fadeInUpBig"
data-wow-delay="0.2s">
<div class="product-img">
<img src="<?php echo $RUTA; ?>/archivos/img/productos/<?php echo($producto['image_producto']); ?>" alt="producto" />
<div class="product-quicview">
<a href="#" data-toggle="modal" data-target="#quickview<?php echo($producto['id_producto']); ?>"
><i class="ti-plus"></i
></a>
</div>
</div>
<div class="product-description">
<h4 class="product-price">$<?php echo($producto['precio_producto']); ?></h4>
<p><?php echo($producto['nombre_producto']); ?></p>
<a href="#" class="add-to-cart-btn text-uppercase"
data-toggle="modal" data-target="#quickview<?php echo($producto['id_producto']); ?>">Añadir</a>
</div>
</div>
<?php include('vistas/modales/modal_producto.php'); ?>
<?php endforeach; ?>
</div>
</div>
</div>
</div>
</div>
</section>
<?php require_once('vistas/footer.php'); ?>
</div>
<?php require_once('vistas/scripts.php'); ?>
</body>
</html>