
Fatal error: Using $this when not in object contexto
Publicado por hermes augusto (1 intervención) el 16/10/2017 11:34:06
me podrias ayudar llevo mas des tres días despierto creo que mi cerebro ya no cuadra al tratar de es un carrito de compras atraves de ajax y php el detalle es que cuando ejecito al querer agregar me indica un problema con esto lel problema lo arroja al querer ejecutar la funcion update_cart();
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
<?php
require_once 'Conexion.php';
class Car{
public $cart = array();
public function __construct(){
if(isset($_SESSION['cart'])){
$this->cart = $_SESSION['cart'];
}
}
public function addCar($c_articulo){
$status = 0;
$conexion = new Conexion ();
$consulta = $conexion->prepare('SELECT * FROM articulos WHERE clave_articulo = :id');
$consulta->bindParam(':id',$c_articulo);
$consulta->execute();
$search = $consulta->fetchAll();
foreach($search as $info){
$id = $info['clave_articulo'];
$descripcion = $info['descripcion'];
$modelo = $info['modelo'];
$precio_a = $info['precio'];
$existencia = $info['existencia'];
$status++;
}
$conf = $conexion->prepare('SELECT * FROM confgen ');
$conf->execute();
$row = $conf->fetchAll();
foreach($row as $credito){
$financiamiento = $credito['t_financiamiento'];
$eganche = $credito['enganche'];
$p_maximo = $credito['p_maximo'];
}
(float)$precio = $precio_a*(1+($financiamiento*$p_maximo)/100);
if($status > 0){
$cantidad='';
$importe='';
$item = array(
'c_artticulo' =>$id,
'descripcion' =>$descripcion,
'modelo' =>$modelo,
'precio' =>$precio,
'cantidad' =>$cantidad,
'importe' =>$importe
);
if(!empty($cart)){
foreach ($this->cart as $key){
if($key['c_artticulo'] == $id){
$item['catidad'] = $key['catidad'] + $item['catidad'];
}
}
}
$folio = md5($id);
$_SESSION['cart'][$folio] = $item;
$this->update_cart();
}
}
public function getCar(){
$html = '';
if(!empty($cart)){
foreach ($this->cart as $key){
$folio = "'".$key['c_artticulo']."'";
$html .= '<tr>
<td>'.$key['descripcion'].'</td>
<td>'.$key['modelo'].'</td>
<td align="right">'.$key['cantidad'].'</td>
<td align="right">$ '.number_format($key['precio'], 2).'</td>
<td align="right">'.number_format($key['importe'], 2).'</td>
<td>
<button onClick="deleteProduct('.$folio.');">
Eliminar
</button>
</td>
</tr>';
}
}
return $html;
}
public function update_cart(){
self::__construct();
}
}
?>
Valora esta pregunta


0