afficher le prix total des produits qui ont été ajoutés au panier

Par Motel, il y a 8 ans


Bonjour,

j'ai un problème avec mon code PHP je cherche comment afficher le prix total des produits qui ont été ajoutés au panier.

Voici ma function

public function panier($client) { $id = $client; $cart_token = $this->db->query("SELECT * FROM panier WHERE client = ?", [$id])->fetchALL(); foreach ($cart_token as $key) { $cart = $this->db->query("SELECT * FROM produits WHERE token = ?", [$key->token])->fetch(); $image = "../themes/img/p/dft/"; echo "<div class='cart-content'> <div class='cart-title'>".$cart->name."</div> <div class='cart-block'> <img src=".$image.$cart->image."> <div class='info'> <div class='cart-price'>Prix : <span class='old'>".$cart->price."</span></div> </div> </div> </div>"; }

3 réponses

Carouge10, il y a 8 ans

Bonsoir,
L'addition sera ta salution.

Motel, il y a 8 ans

Oui mais justement je fais comment c'est là où je suis bloquer :/

Carouge10, il y a 8 ans

$total += $cart->price .... je te laisse faire le reste et le placer